[REBOL] Re: Rebol (fwd)
From: fantam:mailandnews at: 20-Oct-2000 0:38
> Regarding your scripts. Like you I have a need to upload files, but I also
> have a need to download files regularly. I would appreciate it if you could
> describe how your script checks for a connection and how it has been
> installed as a service under windows NT. I've other uses in mind for such a
> capability.
On my setup, the rebol function 'connected? isn't reliable. I think
this is due to the fact I have both a network card and a modem (pc
cards on a laptop), so I had to find another way to check for a
connection.
The solution I retained is a batch file that loops and spits every
minute the following standard NT command : route.exe print > route.txt
The Rebol script on its turn reads every minute "route.txt" and
compares it with the not-connected route (localhost).
This is what I call the default route :
default-route:
{===========================================================================
Interface List
0x1 ........................... MS TCP Loopback interface
0x2 ...00 00 00 00 00 00 ...... NdisWan Adapter
===========================================================================
===========================================================================
Active Routes:
Network Destination Netmask Gateway Interface Metric
127.0.0.0 255.0.0.0 127.0.0.1 127.0.0.1 1
255.255.255.255 255.255.255.255 255.255.255.255 2 1
===========================================================================
}
So now, the following very simple check tells you if you're connected
or not :
forever [ wait 00:01
now-route: read %route.txt
either [now-route = default-route] [connected: to-logic false][connected: to-logic true]
either connected [
print "connected"
do %whatever-you-want-to-do-when-connected.r
]
[
print "not connected"
do %whatever-you-want-to-do-when-not-connected.r
]
]
Regarding your second question concerning NT services, you need a file
called srvany.exe available for free from the NT resource kit (or some
truncated version of the resource kit that you can download on the
Microsoft web site).
Hope this helps, fantam