home *** CD-ROM | disk | FTP | other *** search
/ OS/2 Shareware BBS: 35 Internet / 35-Internet.zip / sendip21.zip / sendip.cmd next >
OS/2 REXX Batch file  |  1996-12-08  |  4KB  |  121 lines

  1. /* REXX -- SENDIP.CMD Ver. 2.0
  2.  
  3.    Send dynamic IP via email to addressee of your choice.
  4.    Some ISP's allow you to keep a line up 24 hours/day with
  5.    the caviat that you drop the line at least once in that
  6.    period -- this prog allows that to happen while keeping you
  7.    advised of the new IP on reconnecting so you can always reach
  8.    your private site from work or school or where ever.
  9.  
  10.    Run this from a cron job once a day or however often your ISP
  11.    requires.
  12.  
  13.    From: Dennis Peterson
  14.    Free to the world
  15. */
  16.  
  17. Call RxFuncAdd 'SysLoadFuncs', 'RexxUtil', 'SysLoadFuncs'
  18. Call SysLoadFuncs
  19.  
  20. Signal On Halt Name CLEANUP
  21.  
  22. /* Use your favorite means to restart your PPP/SLIP session */
  23. /* 'restart_PPP' */
  24.  
  25. CRLF='0d0a'x
  26.  
  27. /********************************************
  28.  *
  29.  *                  NOTE: 
  30.  *     You MUST fill in the following entries
  31.  *
  32.  ********************************************/
  33.  
  34. /* Enter any comments you wish to have placed in the body of the message.
  35.    This text will be placed following the host name and IP information.
  36.    If you wish to have no comments then leave this blank.
  37.    e.g. Comments = ""
  38. */
  39. Comments = 'http://www.visit_me.edu'
  40.  
  41. /* Enter your timezone - default is for left coast, USA */
  42. TZ = "PST8PDT"
  43.  
  44. /* set up the address lists
  45.    e.g. From = 'slickwilly@whitehouse.gov (Slick Willy)' || CRLF
  46. */
  47.  
  48. From = "your_name@domain.com (First Last)" || CRLF
  49. Reply_to = "your_name@domain.com (First Last)" || CRLF
  50.  
  51. /* Build list of recipients. Add any number of names to CC list. Separate
  52.    names with a comma character.
  53.    e.g.: CC = "meatball@hoser.com,wahoo@mindless.com,hairball@cathouse.com"
  54. */
  55.  
  56. To = "some_name@some_domain.com" || CRLF
  57. CC = "another_name@some_domain.com" /* do not add CRLF to this line */
  58. Subject = "Today's New IP" || CRLF || CRLF
  59.  
  60. /******************************************
  61.  *
  62.  *     No user-defined variables below here
  63.  *
  64. ******************************************/
  65.  
  66. Outfile = 'new_ip.fil'
  67. Call SysFileDelete Outfile
  68.  
  69. /* let's create a queue for the new IP */
  70. newq = RxQueue("create")
  71. Call RxQueue 'set', newq
  72.  
  73. /* Now get the host name and IP and put them in the queue.
  74.    Use OS/2's hostname.exe to get host name and ping.exe to
  75.    get the IP. Can also use netstat.exe and a different parsing
  76.    template if you have a netcard and a tcp/ip network installed.
  77. */
  78. '@hostname | RxQueue' newq
  79. Parse Pull Host_Name
  80. '@ping' Host_Name '1 1 | RxQueue' newq
  81.  
  82. /* remove unneeded line from queue then get the IP */
  83. Pull .
  84. Parse Pull . 'bytes from ' IP ':' .
  85.  
  86. /* Now flush the queue */
  87. Do While Queued() > 0
  88.    Parse Pull .
  89. end
  90.  
  91. /* now get the time and date and bundle all the header info into
  92.    an RFC822 format for sendmail
  93. */
  94. Parse Value Date() With Today Month Year
  95. Day = Left(Date('W'),3)
  96. Year = Right(Year,2)
  97. Parse Value Time('L') With Hour':'Minutes':'Seconds'.'Hundredths
  98.  
  99. Message = 'Date: '|| Left(Date('W'),3) ||', '||,
  100.            Today Month Year Hour || ':' || Minutes || ':' ||,
  101.            Seconds || ':' ||,
  102.            Left(Hundredths,2) TZ || CRLF ||,
  103.            'From: ' || From ||,
  104.            'Reply-to: ' || Reply_to ||,
  105.            'To: ' || To ||,
  106.            'CC: ' || CC || CRLF ||,
  107.            'Subject: ' || Subject ||,
  108.            'Host name =' Host_Name || CRLF ||,
  109.            'IP =' IP || CRLF || CRLF ||,
  110.            Comments
  111.  
  112. Call Lineout Outfile, Message
  113. Call Lineout Outfile
  114.  
  115. /* now send it off */
  116. 'sendmail -t -a' Outfile
  117.  
  118. CLEANUP:
  119.    Call RXQueue "delete", newq
  120.    Exit  /* Rexx */
  121.