home *** CD-ROM | disk | FTP | other *** search
/ MACD 7 / MACD7.iso / internet / inet_cash / inet_online.rexx < prev    next >
Encoding:
OS/2 REXX Batch file  |  1998-03-07  |  2.8 KB  |  82 lines

  1. /* Name     : INET_Online.rexx
  2. ** Author   : Jim Dutton  (jimd@siu.edu)
  3. ** Date     : 22 Feb 1998
  4. ** Version  : 1.0
  5. ** PreReq's : ARexx, INet-255 (Interworks TCP/IP)
  6. **
  7. ** CoReq's  : INET_Offline.rexx
  8. **
  9. ** Function : Display a (relatively) small console window wherein
  10. **            the current amount of time (minutes) "online" is displayed
  11. **
  12. ** Caveats  : As with any other Shell/CLI window, accidently moving
  13. **            cursor in the window interrupts output
  14. **
  15. ** Benie's  : Initial window can be resized and moved as desired
  16. **
  17. ** Comments : ARexx must be up and running before Inet is;
  18. **            Modify the initial window size as needed;
  19. **            The console window closes automatically after Inet
  20. **            goes offline (via Stop...), after the 15 (sec) pause at the bottom
  21. **
  22. ** Usage    : Place this and the other programs in an Inet subdirectory;
  23. **            Add the following line to each Start... Inet script for
  24. **            dial-up connections, before the 'SetEnv HOSTNAME' line:
  25. **
  26. **               Run rexxc:rx inet:<path>/INET_Online <phone number>
  27. **
  28. **            Add the following line to each Stop.... Inet script for
  29. **            dial-up connections:
  30. **
  31. **               rexxc:rx inet:<path>/INET_Offline
  32. *
  33. */
  34.  
  35. startup.time = time();  duh = time(reset); parse arg inet_online_phonenum .
  36.  
  37. If ~open(console,"CON:1/1/500/70/INET_Online_Console")  then
  38.     Do; say "*** Can't open 'INET_Online_Console' ***"; Exit 32; End
  39.  
  40. duh = writeln(console,inet_online_phonenum"   INET ONLINE at" startup.time)
  41.  
  42. If ~show("L","rexxsupport.library")  then
  43.     duh = addlib("rexxsupport.library",0,-30,0)
  44.  
  45. If ~openport(INET_Online_Console)  then
  46.     Do
  47.         duh = writeln(console,"*** Can't open 'INET_Online_Console' port ***")
  48.         address "COMMAND" "WAIT 5";  duh = close(console); Exit 33
  49.     End
  50.  
  51. close_port = no;  null_packet = '0000 0000'x; lastElapsedINT = 0;  stoptime = 0
  52.  
  53. Do while close_port = no
  54.     packet_addr = getpkt(INET_Online_Console)
  55.     If packet_addr = null_packet  then  address 'COMMAND' 'WAIT 10'
  56.     Else
  57.         Do
  58.             packet.time = time();  packet_msg = getarg(packet_addr,0);    duh = reply(packet_addr,0)
  59.  
  60.             If subword(packet_msg,1,2) = "INET Offline"  then
  61.                 Do            
  62.                   close_port = yes;  parse var packet_msg . . . stoptime .
  63.                     duh = writeln(console,inet_online_phonenum"   INET went ONLINE  at:" startup.time)
  64.                     duh = writeln(console,inet_online_phonenum"   INET went OFFLINE at:" stoptime)
  65.                     duh = writeln(console,"-- Offline packet time =" packet.time)
  66.                 End
  67.             Else
  68.                 duh = writeln(console,packet_msg)
  69.         End
  70.  
  71.     ElapsedINT = time(elapsed)%60
  72.     If ElapsedINT > lastElapsedINT  then
  73.         Do
  74.             duh = writeln(console,inet_online_phonenum"   Minutes Online:" ElapsedINT)
  75.             lastElapsedINT = ElapsedINT
  76.         End
  77. End
  78.  
  79. duh = closeport(INET_Online_Console);  address "COMMAND" "WAIT 15"
  80. duh = close(console)
  81. Exit
  82.