home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
OS/2 Shareware BBS: 16 Announce
/
16-Announce.zip
/
icwatch.zip
/
ICWATCH.DOC
Wrap
Text File
|
1995-07-20
|
4KB
|
99 lines
ICWatch.c - Slip or PPP Watchdog process for OS/2 and TCP/IP.
---------------------------------------------------------------
Copyright (c) Secant Technologies, 1995
Author: Nick Knight (nick@secant.com)
FREE!, but available ONLY from our WEB home page:
http://www.secant.com
Programatically "pings" a specified internet address every x
minutes. If the ping fails, uses pstat to find the OS/2 session
handle the Internet connection. If found, that session is
killed, and a batch command file is started that will attempt to
reconnect.
Compiled with BC++ for OS/2 v2.0, linked with the IBM TCP/IP
toolkit.
Change Log
----------
07/14/95 - v1.01. Modified pstat log parser to properly handle
non-SLIP.EXE executable names.
07/16/95 - v1.02. Removed incorrect "log parsing" error message.
07/20/95 - v1.03. The test for named EXE was case sensitive.
Now it isn't.
COPYRIGHT NOTICE
================
I authorize anyone, anywhere to use this program. Source code
may be used/modified as desired. The only stipulation I place on
this work is that it may NOT be sold as-is or in any modified
form.
Please, if you find this utility useful, send a simple note to
nick@secant.com. I'll send the source code to anyone that asks.
DON'T FORGET to visit Secant Technologies' WWW Home page
periodically! Keep up-to-date with any other Internet and OS/2
utilities we produce. http://www.secant.com
HOW IT WORKS
============
ICWatch accepts parameters from the command line. The first is the
Internet address to "text" periodically via "ping". The second is
the minutes to delay between tests, defaulting to 5. The third is
the EXE used for your connection services. This defaults to
SLIP.EXE.
ICWatch starts and immediately sleeps for the specified delay time.
This allows a "boot up" connection to be made before pinging.
It then attempts to ping the given address 10 times. If any time
succeeds, it sleeps and waits for the next period. If it fails, it
delays for 5 seconds and pings 10 more times. If ALL pings fail,
it attempts a connection restart.
When a "restart" is called for, ICWatch makes use of teh OS/2 PSTAT
utility to create a text log of processes. I could not find a
proper call or procedure for doing this programatically. ICWatch
then scans the log file for the pertainent EXE file (ignoring paths,
only the base file name is used, e.g., "SLIP.EXE"). If found,
it extracts the process ID and calls DOSKillProcess on this ID.
If an error occurs, ICWatch reports this and goes to sleep until the
next check. If the KILL succeeds, ICWatch delays 10 seconds to make
sure the KILL completes, then starts a new command line session,
invoking the batch file "reslip" (no directory specified). It then
sleeps and will check again in the specified number of minutes.
HINTS: Use the same or a similar batch file to start SLIP originally.
To get rid of the SLIP session and its command shell, a batch file
with an "EXIT" at the end works well. For example, the reslip.cmd
I use looks like:
--------------------------------------------
/*
*/
'@echo off'
say 'Reconnecting on ' ||DATE()||' at '||TIME()
'echo Reconnecting on ' ||DATE()||' at '||TIME()|| '>>slip.log'
rem 'start "Slip Connection" /min slip'
'slip'
'exit'
--------------------------------------------
NOTE that we log all booting and SLIP restart utility to a log.
REXX is used for this batch file, simply to format the date and
time nicely. The file could simple consist of the line "slip"
and then "exit".
SOURCE CODE? Simply ask. email me at nick@secant.com.