home *** CD-ROM | disk | FTP | other *** search
/ OS/2 Shareware BBS: 35 Internet / 35-Internet.zip / wdn.zip / WDN.CMD next >
OS/2 REXX Batch file  |  1995-04-20  |  12KB  |  274 lines

  1. /*--------------------------------------------------------------------------*/
  2. /*                                                                          */
  3. /*        OS/2 / WARP REX Driver for IBM TCP/IP version 2.0 / IAK           */
  4. /*                                                                          */
  5. /*                                WDN.CMD                                   */
  6. /*                                   modified by jerry woolsey              */
  7. /*            ..................................................            */
  8. /*                                                                          */
  9. /*          This is a modification to the annex.cmd supplied with IAK.      */
  10. /*    I have modified the main routine and the waitfor subroutine.  You     */
  11. /*    need to make three manual changes to this script -                    */
  12. /*                                                                          */
  13. /*         1)  Insert the initialization string you need (should be the     */
  14. /*                 same as the one you use for your normal terminal program */
  15. /*                 to log onto WDN.  "ATZ" is enough for most.  I get a lot */
  16. /*                 of Carrier drops at 28.8K so I use AT%C0S37=20, which    */
  17. /*                 corrects my problems (caused by my crappy phone line).   */
  18. /*                                                                          */
  19. /*         2)  Insert your name and password into the logon input line      */
  20. /*                 below.  I've always inserted the full name and password  */
  21. /*                 on one line, so I made the script that way (and it made  */
  22. /*                 the script easier.                                       */
  23. /*                                                                          */
  24. /*         3)  Insert your first name (or whatever WDN uses) as the prompt  */
  25. /*                 the script is looking for before sending the "slip"      */
  26. /*                 command.                                                 */
  27. /*                                                                          */
  28. /*         Place the script into c:\tcpip\bin                               */
  29. /*                                                                          */
  30. /*           Use the following settings in the Dial Other Internet Providers*/
  31. /*    setup screen:                                                         */
  32. /*      1st page:                                                           */
  33. /*         Provider Name:  wdn.com                                          */
  34. /*         Login ID:       <blank>                                          */
  35. /*         Password:       <blank> (uncheck box if you have the new version)*/
  36. /*         Nickname:       WDN                                              */
  37. /*         Phone Number:   <blank>                                          */
  38. /*         Login script:   wdn.cmd atdt620-8900                             */
  39. /*         Connection type:  select button for SLIP                         */
  40. /*                                                                          */
  41. /*      2nd page:                                                           */
  42. /*         Your IP address, Destination IP Address, and Netmask should be   */
  43. /*              greyed out (left blank)                                     */
  44. /*         MTU Size:           1006                                         */
  45. /*         VJ Compression check box - YES                                   */
  46. /*         Domain Nameserver:  199.0.216.4                                  */
  47. /*         Your Host Name:     <blank>                                      */
  48. /*         Your Domain Name:   wdn.com                                      */
  49. /*                                                                          */
  50. /*      3rd page:                                                           */
  51. /*         All can be left blank - or fill in defaults you want             */
  52. /*                                                                          */
  53. /*      4th page:                                                           */
  54. /*         Hopefully you know what to fill in here for comm port            */
  55. /*         Speed should be 57600, 8 bits, no parity                         */
  56. /*                                                                          */
  57. /*       GOOD LUCK -                                                        */
  58. /*--------------------------------------------------------------------------*/
  59.  
  60.  
  61. parse arg interface , dialcmd
  62.  
  63. /*--------------------------------------------------------------------------*/
  64. /*                   Initialization and Main Script Code                    */
  65. /*--------------------------------------------------------------------------*/
  66.  
  67. /* Set some definitions for easier COM strings */
  68. cr='0d'x
  69. crlf='0d0a'x
  70.  
  71. say ''
  72. say 'WDN - SLIP WDN Example Connection Script ',
  73.     '(interface' interface')'
  74.  
  75. /* Flush any stuff left over from previous COM activity */
  76. call flush_receive
  77.  
  78. /* Reset the modem here */
  79. /* You may need to customize this for your modem make and model */
  80.  
  81. call lineout , 'Reset modem...'
  82. /*  Use your own initialization string                          */
  83. call send 'ATZ' || cr
  84. call waitfor 'OK', 5 ; call flush_receive 'echo'
  85.  if RC = 1 then do
  86.     call lineout , 'Modem not resetting... Trying again'
  87.     call send '+++'
  88.     call waitfor 'OK'
  89.     call send 'ATHZ' || cr
  90.     call waitfor 'OK', 3
  91.   end
  92.  
  93. /* Dial the remote server */
  94. call charout , 'Now Dialing...'
  95.  
  96. /* Wait for connection */
  97. call send dialcmd || cr
  98. call waitfor 'CONNECT' ; call waitfor crlf
  99.  
  100. /* Handle login.  We wait for standard strings, and then flush anything */
  101. /* else to take care of trailing spaces, etc..                          */
  102. call send cr
  103. call waitfor 'change?' ; call flush_receive 'echo'
  104. call send 'n' || cr
  105. call waitfor '?' ; call flush_receive 'echo'
  106. call send 'n' || cr
  107. call waitfor 'Name?' ; call flush_receive 'echo'
  108.  
  109. /*   Need to modifiy these two lines to you name and password for logon */
  110. /*   and name used in prompts                                           */
  111.  
  112. call send 'jerry woolsey password' || cr
  113. call waitfor 'Jerry?' ; call flush_receive 'echo'
  114. call send 'slip' || cr
  115.  
  116. call waitfor 'Slip'
  117. call waitfor 'you'
  118. parse var waitfor_buffer . 'server is' a '.' b '.' c '.' d ',' .
  119. wdn_address = a||'.'||b||'.'||c||'.'||d
  120. call waitfor crlf
  121. parse var waitfor_buffer . 'are' a '.' b '.' c '.' d .
  122. os2_address = a||'.'||b||'.'||c||'.'||d
  123.  
  124. /* Flush anything else */
  125. call flush_receive 'echo'
  126.  
  127. say 'SLIP Connection Established'
  128. say 'Configuring local address =' os2_address ', wdn =' wdn_address
  129.  
  130. 'ifconfig sl0' os2_address wdn_address 'netmask 255.255.255.0'
  131. 'route add default' wdn_address '1'
  132.  
  133. /* All done */
  134. exit 0
  135.  
  136.  
  137. /*--------------------------------------------------------------------------*/
  138. /*                            send ( sendstring)                            */
  139. /*..........................................................................*/
  140. /*                                                                          */
  141. /* Routine to send a character string off to the modem.                     */
  142. /*                 NOT MODIFIED                                             */
  143. /*--------------------------------------------------------------------------*/
  144.  
  145. send:
  146.  
  147.    parse arg sendstring
  148.    call slip_com_output interface , sendstring
  149.  
  150.    return
  151.  
  152.  
  153. /*--------------------------------------------------------------------------*/
  154. /*                    waitfor ( waitstring , [timeout] )                    */
  155. /*..........................................................................*/
  156. /*                    (MODIFIED FOR WDN SLIP)                               */
  157. /* Waits for the supplied string to show up in the COM input.  All input    */
  158. /* from the time this function is called until the string shows up in the   */
  159. /* input is accumulated in the "waitfor_buffer" variable.                   */
  160. /*                                                                          */
  161. /* If timeout is specified, it says how long to wait if data stops showing  */
  162. /* up on the COM port (in seconds).                                         */
  163. /*                                                                          */
  164. /*--------------------------------------------------------------------------*/
  165.  
  166. waitfor:
  167.  
  168.    parse arg waitstring , timeout
  169.  
  170.    if timeout = '' then
  171.      timeout = 1000    /* L O N G   delay if not specified */
  172.    waitfor_buffer = '' ; done = -1; curpos = 1
  173.    ORI_TIME=TIME('E')
  174.  
  175.    if (remain_buffer = 'REMAIN_BUFFER') then do
  176.       remain_buffer = ''
  177.    end
  178.  
  179.    do while (done = -1)
  180.       if (remain_buffer \= '') then do
  181.          line = remain_buffer
  182.          remain_buffer = ''
  183.        end
  184.        else do
  185.          line = slip_com_input(interface,,10)
  186.       end
  187.       waitfor_buffer = waitfor_buffer || line
  188.  
  189. /*  Look for More? or continue prompts during logon - bypass them    */
  190.  
  191.       if (pos('More?',waitfor_buffer)>0) then do
  192.          call flush_receive 'echo'
  193.          waitfor_buffer = '' ; curpos = 1
  194.          call send 'n' || cr
  195.       end
  196.       if (pos('ontinue?',waitfor_buffer)>0) then do
  197.          call flush_receive 'echo'
  198.          waitfor_buffer = '' ; curpos = 1
  199.          call send '' || cr
  200.       end
  201.       index = pos(waitstring,waitfor_buffer)
  202.       if (index > 0) then do
  203.          remain_buffer = substr(waitfor_buffer,index+length(waitstring))
  204.          waitfor_buffer = delstr(waitfor_buffer,index+length(waitstring))
  205.          done = 0
  206.       end
  207.       call charout , substr(waitfor_buffer,curpos)
  208.       curpos = length(waitfor_buffer)+1
  209.       if ((done \= 0) & (TIME('E')>timeout)) then do
  210.         call lineout , ' WAITFOR: timed out '
  211.         done = 1
  212.        end
  213.    end
  214.    timeout=0
  215.    RC=done
  216.  return RC
  217.  
  218.  
  219.  
  220. /*--------------------------------------------------------------------------*/
  221. /*                               readpass ()                                */
  222. /*..........................................................................*/
  223. /*                                                                          */
  224. /* Routine used to read a password from the user without echoing the        */
  225. /* password to the screen.                                                  */
  226. /*                       NOT MODIFIED                                       */
  227. /*--------------------------------------------------------------------------*/
  228.  
  229. readpass:
  230.  
  231.   answer = ''
  232.   do until key = cr
  233.     key = slip_getch()
  234.     if key \= cr then do
  235.       answer = answer || key
  236.     end
  237.   end
  238.   say ''
  239.   return answer
  240.  
  241.  
  242. /*--------------------------------------------------------------------------*/
  243. /*                             flush_receive ()                             */
  244. /*..........................................................................*/
  245. /*                             NOT MODIFIED                                 */
  246. /* Routine to flush any pending characters to be read from the COM port.    */
  247. /* Reads everything it can until nothing new shows up for 100ms, at which   */
  248. /* point it returns.                                                        */
  249. /*                                                                          */
  250. /* The optional echo argument, if 1, says to echo flushed information.      */
  251. /*                                                                          */
  252. /*--------------------------------------------------------------------------*/
  253.  
  254. flush_receive:
  255.  
  256.    parse arg echo
  257.  
  258.    /* If echoing the flush - take care of waitfor remaining buffer */
  259.    if (echo \= '') & (length(remain_buffer) > 0) then do
  260.       call charout , remain_buffer
  261.       remain_buffer = ''
  262.    end
  263.  
  264.    /* Eat anything left in the modem or COM buffers */
  265.    /* Stop when nothing new appears for 100ms.      */
  266.  
  267.    do until line = ''
  268.      line = slip_com_input(interface,,100)
  269.      if echo \= '' then
  270.         call charout , line
  271.    end
  272.  
  273.    return
  274.