home *** CD-ROM | disk | FTP | other *** search
/ OS/2 Shareware BBS: 35 Internet / 35-Internet.zip / helix.zip / helix.cmd next >
OS/2 REXX Batch file  |  1994-12-05  |  7KB  |  214 lines

  1. /* Helix Logon Script for OS/2 Warp Version 3 */
  2. /* Created: October 28, 1994                            */
  3. /* Tested: December 5, 1994                             */
  4.  
  5. /* ****************************************** */
  6. /* IMPORTANT: This script was tested using the dialer */
  7. /* settings outlined in HELIX.TXT. You should read that */
  8. /* file (should be in this zip) before attempting to */
  9. /* connect. */
  10. /* ****************************************** */
  11.  
  12. parse arg interface , dialcmd username password
  13.  
  14. /*--------------------------------------------------------------------------*/
  15. /*                   Initialization and Main Script Code                    */
  16. /*--------------------------------------------------------------------------*/
  17.  
  18. reset_modem='ATZ'
  19. init_modem='AT&F1'    /* This init string works with 99% of modems...only change if neccessary */
  20. hangup_modem='ATH'
  21.  
  22. cr='0d'x
  23. crlf='0d0a'x
  24.  
  25.  
  26. 'route -fh'
  27.  
  28. helix_route = '142.231.37.2'
  29. helix_local_ip = '192.0.2.1'
  30.  
  31. say 'Helix OS/2 Warp SLIP Login Script ',
  32.     '(interface' interface')'
  33.  
  34.  
  35. /* Flush any stuff left over from previous COM activity */
  36. call flush_receive
  37.  
  38. /* Reset the modem here */
  39.  
  40. call lineout , 'Reset modem...'
  41. call send init_modem || cr
  42. call waitfor 'OK', 5 ; call flush_receive 'echo'
  43.  if RC = 1 then do
  44.     call lineout , 'Modem not resetting... Trying again'
  45.     call send '+++'
  46.     call waitfor 'OK'
  47.     call send hangup_modem || cr
  48.     call waitfor 'OK', 3
  49.   end
  50.  
  51. /* Dial the remote server */
  52. call charout , 'Now Dialing...'
  53.  
  54. /* Wait for connection */
  55. call send dialcmd || cr
  56. call waitfor 'CONNECT' ; call waitfor crlf, 5
  57. call flush_receive 'echo'
  58.  
  59. /* Handle login.  We wait for standard strings, and then flush anything */
  60. /* else to take care of trailing spaces, etc..                          */
  61. /* call send cr */
  62.  
  63. call send cr
  64. call waitfor 'login:' ; call flush_receive 'echo'
  65. call send username || cr
  66. call waitfor 'Password:' ; call flush_receive 'echo'
  67. call send password || cr
  68.  
  69. call waitfor '(? for help) >'; call flush_receive 'echo'
  70. call send 'TIA' || cr
  71.  
  72. os2_address = helix_local_ip
  73. annex_address = helix_route
  74.  
  75. /* Now configure this host for the appropriate address, */
  76. /* and for a default route through the Annex.           */
  77.  
  78. say 'SLIP Connection Established'
  79. say 'Configuring local address =' os2_address ', Annex =' annex_address
  80.  
  81.  
  82. 'ifconfig sl0' os2_address' 'annex_address ' netmask 255.255.255.0'
  83. 'route add default 'annex_address' 1'
  84.  
  85.  
  86. /* All done */
  87. exit 0
  88.  
  89.  
  90. /*--------------------------------------------------------------------------*/
  91. /*                            send ( sendstring)                            */
  92. /*..........................................................................*/
  93. /*                                                                          */
  94. /* Routine to send a character string off to the modem.                     */
  95. /*                                                                          */
  96. /*--------------------------------------------------------------------------*/
  97.  
  98. send:
  99.  
  100.    parse arg sendstring
  101.    call slip_com_output interface , sendstring
  102.  
  103.    return
  104.  
  105.  
  106. /*--------------------------------------------------------------------------*/
  107. /*                    waitfor ( waitstring , [timeout] )                    */
  108. /*..........................................................................*/
  109. /*                                                                          */
  110. /* Waits for the supplied string to show up in the COM input.  All input    */
  111. /* from the time this function is called until the string shows up in the   */
  112. /* input is accumulated in the "waitfor_buffer" variable.                   */
  113. /*                                                                          */
  114. /* If timeout is specified, it says how long to wait if data stops showing  */
  115. /* up on the COM port (in seconds).                                                         */
  116. /*                                                                          */
  117. /*--------------------------------------------------------------------------*/
  118.  
  119. waitfor:
  120.  
  121.    parse arg waitstring , timeout
  122.  
  123.    if timeout = '' then
  124.      timeout = 5000    /* L O N G   delay if not specified */
  125.    waitfor_buffer = '' ; done = -1; curpos = 1
  126.    ORI_TIME=TIME('E')
  127.  
  128.    if (remain_buffer = 'REMAIN_BUFFER') then do
  129.       remain_buffer = ''
  130.    end
  131.  
  132.    do while (done = -1)
  133.       if (remain_buffer \= '') then do
  134.          line = remain_buffer
  135.          remain_buffer = ''
  136.        end
  137.        else do
  138.          line = slip_com_input(interface,,10)
  139.       end
  140.       waitfor_buffer = waitfor_buffer || line
  141.       index = pos(waitstring,waitfor_buffer)
  142.       if (index > 0) then do
  143.          remain_buffer = substr(waitfor_buffer,index+length(waitstring))
  144.          waitfor_buffer = delstr(waitfor_buffer,index+length(waitstring))
  145.          done = 0
  146.       end
  147.       call charout , substr(waitfor_buffer,curpos)
  148.       curpos = length(waitfor_buffer)+1
  149.       if ((done \= 0) & (TIME('E')>timeout)) then do
  150.         call lineout , ' WAITFOR: timed out '
  151.         done = 1
  152.        end
  153.    end
  154.    timeout=0
  155.    RC=done
  156.  return RC
  157.  
  158.  
  159.  
  160. /*--------------------------------------------------------------------------*/
  161. /*                               readpass ()                                */
  162. /*..........................................................................*/
  163. /*                                                                          */
  164. /* Routine used to read a password from the user without echoing the        */
  165. /* password to the screen.                                                  */
  166. /*                                                                          */
  167. /*--------------------------------------------------------------------------*/
  168.  
  169. readpass:
  170.  
  171.   answer = ''
  172.   do until key = cr
  173.     key = slip_getch()
  174.     if key \= cr then do
  175.       answer = answer || key
  176.     end
  177.   end
  178.   say ''
  179.   return answer
  180.  
  181.  
  182. /*--------------------------------------------------------------------------*/
  183. /*                             flush_receive ()                             */
  184. /*..........................................................................*/
  185. /*                                                                          */
  186. /* Routine to flush any pending characters to be read from the COM port.    */
  187. /* Reads everything it can until nothing new shows up for 100ms, at which   */
  188. /* point it returns.                                                        */
  189. /*                                                                          */
  190. /* The optional echo argument, if 1, says to echo flushed information.      */
  191. /*                                                                          */
  192. /*--------------------------------------------------------------------------*/
  193.  
  194. flush_receive:
  195.  
  196.    parse arg echo
  197.  
  198.    /* If echoing the flush - take care of waitfor remaining buffer */
  199.    if (echo \= '') & (length(remain_buffer) > 0) then do
  200.       call charout , remain_buffer
  201.       remain_buffer = ''
  202.    end
  203.  
  204.    /* Eat anything left in the modem or COM buffers */
  205.    /* Stop when nothing new appears for 100ms.      */
  206.  
  207.    do until line = ''
  208.      line = slip_com_input(interface,,100)
  209.      if echo \= '' then
  210.         call charout , line
  211.    end
  212.  
  213.    return
  214.