home *** CD-ROM | disk | FTP | other *** search
/ OS/2 Shareware BBS: 16 Announce / 16-Announce.zip / icwatch.zip / ICWATCH.DOC
Text File  |  1995-07-20  |  4KB  |  99 lines

  1.  
  2. ICWatch.c - Slip or PPP Watchdog process for OS/2 and TCP/IP.
  3. ---------------------------------------------------------------
  4.  
  5. Copyright (c) Secant Technologies, 1995
  6. Author: Nick Knight (nick@secant.com)
  7.  
  8. FREE!, but available ONLY from our WEB home page:
  9.        http://www.secant.com
  10.  
  11. Programatically "pings" a specified internet address every x 
  12. minutes.  If the ping fails, uses pstat to find the OS/2 session 
  13. handle the Internet connection.  If found, that session is 
  14. killed, and a batch command file is started that will attempt to 
  15. reconnect.
  16.     
  17. Compiled with BC++ for OS/2 v2.0, linked with the IBM TCP/IP
  18. toolkit.
  19.  
  20. Change Log
  21. ----------
  22.  
  23. 07/14/95 - v1.01.  Modified pstat log parser to properly handle
  24.            non-SLIP.EXE executable names.
  25.  
  26. 07/16/95 - v1.02.  Removed incorrect "log parsing" error message.           
  27.  
  28. 07/20/95 - v1.03.  The test for named EXE was case sensitive.
  29.            Now it isn't.
  30.  
  31.  
  32. COPYRIGHT NOTICE
  33. ================
  34. I authorize anyone, anywhere to use this program.  Source code 
  35. may be used/modified as desired.  The only stipulation I place on 
  36. this work is that it may NOT be sold as-is or in any modified 
  37. form.
  38.     
  39. Please, if you find this utility useful, send a simple note to
  40. nick@secant.com.  I'll send the source code to anyone that asks.
  41.     
  42. DON'T FORGET to visit Secant Technologies' WWW Home page 
  43. periodically!  Keep up-to-date with any other Internet and OS/2 
  44. utilities we produce.    http://www.secant.com
  45.     
  46.  
  47. HOW IT WORKS
  48. ============
  49. ICWatch accepts parameters from the command line.  The first is the
  50. Internet address to "text" periodically via "ping".  The second is
  51. the minutes to delay between tests, defaulting to 5.  The third is
  52. the EXE used for your connection services.  This defaults to
  53. SLIP.EXE.
  54.  
  55. ICWatch starts and immediately sleeps for the specified delay time.
  56. This allows a "boot up" connection to be made before pinging. 
  57. It then attempts to ping the given address 10 times.  If any time
  58. succeeds, it sleeps and waits for the next period.  If it fails, it
  59. delays for 5 seconds and pings 10 more times.  If ALL pings fail,
  60. it attempts a connection restart.    
  61.  
  62. When a "restart" is called for, ICWatch makes use of teh OS/2 PSTAT
  63. utility to create a text log of processes.  I could not find a
  64. proper call or procedure for doing this programatically.  ICWatch
  65. then scans the log file for the pertainent EXE file (ignoring paths,
  66. only the base file name is used, e.g., "SLIP.EXE").  If found,
  67. it extracts the process ID and calls DOSKillProcess on this ID.
  68. If an error occurs, ICWatch reports this and goes to sleep until the
  69. next check.  If the KILL succeeds, ICWatch delays 10 seconds to make
  70. sure the KILL completes, then starts a new command line session,
  71. invoking the batch file "reslip" (no directory specified).  It then
  72. sleeps and will check again in the specified number of minutes.
  73.  
  74. HINTS:    Use the same or a similar batch file to start SLIP originally.
  75. To get rid of the SLIP session and its command shell, a batch file
  76. with an "EXIT" at the end works well.  For example, the reslip.cmd
  77. I use looks like:
  78.  
  79. --------------------------------------------
  80.     /*
  81.     */
  82.     '@echo off'
  83.  
  84.     say 'Reconnecting on ' ||DATE()||' at '||TIME()
  85.     'echo Reconnecting on ' ||DATE()||' at '||TIME()|| '>>slip.log'
  86.  
  87.     rem 'start "Slip Connection" /min slip'
  88.     'slip'
  89.     'exit'
  90. --------------------------------------------
  91.  
  92. NOTE that we log all booting and SLIP restart utility to a log.  
  93. REXX is used for this batch file, simply to format the date and
  94. time nicely.  The file could simple consist of the line "slip" 
  95. and then "exit".
  96.  
  97. SOURCE CODE?  Simply ask. email me at nick@secant.com.
  98.  
  99.