home *** CD-ROM | disk | FTP | other *** search
/ OS/2 Shareware BBS: 35 Internet / 35-Internet.zip / autodial.zip / sendip.cmd < prev    next >
OS/2 REXX Batch file  |  1997-05-22  |  4KB  |  143 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. /* The method of finding the IP addres was enhanced to allow the address
  18.    to be found, even if multiple TCP/IP interfaces are used. However,
  19.    the hostanme may be blank or possibly incorrect when multiple
  20.    interfaces are used. Best to use the IP address.
  21.  
  22.    The interface must now be specified. The defaut is the first PPP
  23.    connection. See the bottom of the section the user (you) must fill
  24.    out below .
  25.  
  26.    Change done by Jeff Jackowski (jeffj@ro.com, http://ro.com/~jeffj)
  27. */
  28.  
  29. Call RxFuncAdd 'SysLoadFuncs', 'RexxUtil', 'SysLoadFuncs'
  30. Call SysLoadFuncs
  31.  
  32. Signal On Halt Name CLEANUP
  33.  
  34. /* Use your favorite means to restart your PPP/SLIP session */
  35. /* 'restart_PPP' */
  36.  
  37. CRLF='0d0a'x
  38.  
  39. /********************************************
  40.  *
  41.  *                  NOTE: 
  42.  *     You MUST fill in the following entries
  43.  *
  44.  ********************************************/
  45.  
  46. /* Enter any comments you wish to have placed in the body of the message.
  47.    This text will be placed following the host name and IP information.
  48.    If you wish to have no comments then leave this blank.
  49.    e.g. Comments = ""
  50. */
  51. Comments = ''
  52.  
  53. /* Enter your timezone - default is for left coast, USA */
  54. TZ = "CST"
  55.  
  56. /* set up the address lists
  57.    e.g. From = 'slickwilly@whitehouse.gov (Slick Willy)' || CRLF
  58. */
  59.  
  60. From = "jeffj@ro.com (computer)" || CRLF
  61. Reply_to = "jeffj@ro.com (please don't)" || CRLF
  62.  
  63. /* Build list of recipients. Add any number of names to CC list. Separate
  64.    names with a comma character.
  65.    e.g.: CC = "meatball@hoser.com,wahoo@mindless.com,hairball@cathouse.com"
  66. */
  67.  
  68. To = "me@here.com" || CRLF
  69. CC = "" /* do not add CRLF to this line */
  70. Subject = "Current IP address" || CRLF || CRLF
  71.  
  72. /* Tell it what device to use. ppp0 is the first PPP connection, sl0 is
  73.    the first SLIP connection, lan0 is the first LAN/ethernet connection.
  74.    For the second connection, use the number 1 instead of 0
  75. */
  76.  
  77. INetDevice = 'ppp0'
  78.  
  79. /******************************************
  80.  *
  81.  *     No user-defined variables below here
  82.  *
  83. ******************************************/
  84.  
  85. Outfile = 'new_ip.fil'
  86. Call SysFileDelete Outfile
  87.  
  88. /* let's create a queue for the new IP */
  89. newq = RxQueue("create")
  90. Call RxQueue 'set', newq
  91.  
  92. /* Now get the host name and IP and put them in the queue.
  93.    Use OS/2's hostname.exe to get host name and ping.exe to
  94.    get the IP. Can also use netstat.exe and a different parsing
  95.    template if you have a netcard and a tcp/ip network installed.
  96. */
  97. '@hostname | RxQueue' newq
  98. Parse Pull Host_Name
  99.  
  100. /* The method of finding the IP addres was enhanced to allow the address
  101.    to be found, even if multiple TCP/IP interfaces are used.
  102. */
  103.  
  104. '@ifconfig' INetDevice '| RxQueue' newq
  105. Parse Pull interfacename flags
  106. Parse Pull dumb inet IP extra
  107.  
  108. /* Now flush the queue */
  109. Do While Queued() > 0
  110.    Parse Pull .
  111. end
  112.  
  113. /* now get the time and date and bundle all the header info into
  114.    an RFC822 format for sendmail
  115. */
  116. Parse Value Date() With Today Month Year
  117. Day = Left(Date('W'),3)
  118. Year = Right(Year,2)
  119. Parse Value Time('L') With Hour':'Minutes':'Seconds'.'Hundredths
  120.  
  121. Message = 'Date: '|| Left(Date('W'),3) ||', '||,
  122.            Today Month Year Hour || ':' || Minutes || ':' ||,
  123.            Seconds || ':' ||,
  124.            Left(Hundredths,2) TZ || CRLF ||,
  125.            'From: ' || From ||,
  126.            'Reply-to: ' || Reply_to ||,
  127.            'To: ' || To ||,
  128.            'CC: ' || CC || CRLF ||,
  129.            'Subject: ' || Subject ||,
  130.            'Host name =' Host_Name || CRLF ||,
  131.            'IP =' IP || CRLF || CRLF ||,
  132.            Comments
  133.  
  134. Call Lineout Outfile, Message
  135. Call Lineout Outfile
  136.  
  137. /* now send it off */
  138. 'sendmail -t -a' Outfile
  139.  
  140. CLEANUP:
  141.    Call RXQueue "delete", newq
  142.    Exit  /* Rexx */
  143.