home *** CD-ROM | disk | FTP | other *** search
/ OS/2 Shareware BBS: 35 Internet / 35-Internet.zip / altslp.txt < prev    next >
Text File  |  1994-12-03  |  10KB  |  265 lines

  1.  
  2. #: 270875 S20/Internet IAK (BP)
  3.     18-Nov-94  23:36:13
  4. Sb: Success with Rexx script
  5. Fm: Mike E. Perry 75252,444
  6. To: Orest Skrypuch (Recon) 76672,1273 (X)
  7.  
  8. This is the script that was written by Iceberg@slip.net.  All kudos go to
  9. him.  I can vouch that it works for dynamically assigned slip accounts.  You
  10. will have to change the information regarding internet service provider,
  11. phone number, user id, and password.  Also remember to change modem
  12. instructions from what mine are.  I found that the culprit with my attempts
  13. at this script was that I couldn't get past *connect 14400, etc*.  This was
  14. caused by an incorrect modem string.  This script is also based on not
  15. issuing the *slip* command to your provider to begin TCP/IP.  I have used
  16. this script with all the WARP tools including WebExplorer, news, mail,
  17. gopher, ftp, telnet.  I get darned good ftp dl's with it.  Also this script
  18. parses the "S" before a user's name to get the dynamic address.  Don't know
  19. how this works, but you can read it in the attached info.  I would never have
  20. come up with this in a kazillion years!!
  21.  
  22. Again, thanks to Iceberg@slip.net and all the slipnetters for their continued
  23. patience...  Iceberg tells me that the most important part of the script is
  24. the first part which assigns the IPs.  Good luck, HTH!!
  25.  
  26. >>>>>>>>>>begin slipnet.cmd>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
  27.  
  28. /*--------------------------------------------------------------------------*/
  29. /*                                Slipnet.cmd
  30.  
  31. This rexx script will allow you to use the "Dial Other
  32. Internet Provider' interface to log on to slip.net.  slip.net uses the
  33. username to make the slip call, (the "S" that precedes your
  34. username is the call), then sends your dynamic settings in a
  35. single line string.  The unmodified annex.cmd sends an
  36. unnecessary slip call, (to Slip Net),  and cannot correctly parse the
  37. resulting string.  Slipnet.cmd corrects these problems.
  38.  
  39. This is a modified version of the annex.cmd script found in the /etc
  40. dir of TCPIP.
  41.  
  42. Good luck!  iceberg@slip.net
  43. */
  44. parse arg interface , dialcmd username password
  45. /*--------------------------------------------------------------------------*/
  46. /*                   Initialization and Main Script Code                    */
  47. /*--------------------------------------------------------------------------*/
  48.  
  49. /* Set some definitions for easier COM strings */
  50. cr='0d'x
  51. crlf='0d0a'x
  52.  
  53. say ''
  54. say 'Logon Script for OS/2 Warp to Slipnet ',
  55.     '(interface' interface')'
  56.  
  57. /* Prompt for your username, password, and dialing information */
  58. if dialcmd = '' then do
  59.    call charout , 'Dial Command: '
  60.    parse pull dialcmd
  61. end
  62. if username = '' | username = '*' then do
  63.    call charout , 'User Name: '
  64.    parse pull username
  65. end
  66. else do
  67.    say 'User:' username
  68. end
  69. if password = '' | password = '*' then do
  70.    call charout , 'Password: '
  71.    password = readpass()
  72. end
  73.  
  74. /* Flush any stuff left over from previous COM activity */
  75. call flush_receive
  76.  
  77. /* Reset the modem here */
  78. /* You may need to customize this for your modem make and model */
  79. call lineout , 'Reset modem...'
  80. call send 'ATM0&B1&F1' || cr
  81. call waitfor 'OK', 5 ; call flush_receive 'echo'
  82.  if RC = 1 then do
  83.     call lineout , 'Modem not resetting... Trying again'
  84.     call send '+++'
  85.     call waitfor 'OK'
  86.     call send 'ATHZ' || cr
  87.     call waitfor 'OK', 3
  88.   end
  89.  
  90.  
  91. /* Dial the remote server */
  92.  
  93. call charout , 'Now Dialing...'
  94. call send dialcmd || cr
  95.  
  96. /* Handle login.  We wait for the slipnet strings, and
  97. then flush anything else to take care of trailing spaces, etc.. */
  98.  
  99. call waitfor 'slip.net login:' ; call flush_receive 'echo'
  100. call send username || cr
  101. call waitfor 'Password:' ; call flush_receive 'echo'
  102. call send password || cr
  103.  
  104. /* Parse the results of the SLIP command (the "S" that precedes your*/
  105. /* username)  to determine the correct addresses. */
  106. /* We use the "waitfor_buffer" variable from the waitfor routine   */
  107. /* to parse the single line we get from the Annex after */
  108. /* waiting for an appropriate point in the data stream. */
  109.  
  110. call waitfor '....'
  111. parse var waitfor_buffer '(' a '.' b '.' c '.' d ')' 'to ' e '.' f '.' g '.' h
  112. ' b'
  113. annex_address = a||'.'||b||'.'||c||'.'||d
  114. os2_address = e||'.'||f||'.'||g||'.'||h
  115.  
  116. /* Flush anything else */
  117. call flush_receive 'echo'
  118.  
  119. /* Now configure this host for the appropriate address, */
  120. /* and for a default route through the Annex.           */
  121.  
  122. say 'Slipnet Connection Established'
  123. say 'From 'username' =' os2_address ', To Slip Net =' annex_address
  124.  
  125. 'ifconfig sl0' os2_address annex_address 'netmask 255.255.255.0'
  126. 'route -f add default' annex_address '1'
  127.  
  128. /* All done */
  129. exit 0
  130.  
  131.  
  132. /*--------------------------------------------------------------------------*/
  133. /*                            send ( sendstring)                            */
  134. /*..........................................................................*/
  135. /*                                                                          */
  136. /* Routine to send a character string off to the modem.                     */
  137. /*                                                                          */
  138. /*--------------------------------------------------------------------------*/
  139.  
  140. send:
  141.  
  142.    parse arg sendstring
  143.    call slip_com_output interface , sendstring
  144.  
  145.    return
  146.  
  147.  
  148. /*--------------------------------------------------------------------------*/
  149. /*                    waitfor ( waitstring , [timeout] )                    */
  150. /*..........................................................................*/
  151. /*                                                                          */
  152. /* Waits for the supplied string to show up in the COM input.  All input    */
  153. /* from the time this function is called until the string shows up in the   */
  154. /* input is accumulated in the "waitfor_buffer" variable.                   */
  155. /*                                                                          */
  156. /* If timeout is specified, it says how long to wait if data stops showing  */
  157. /* up on the COM port (in seconds).
  158. */
  159. /*                                                                          */
  160. /*--------------------------------------------------------------------------*/
  161.  
  162. waitfor:
  163.  
  164.    parse arg waitstring , timeout
  165.  
  166.    if timeout = '' then
  167.      timeout = 5000    /* L O N G   delay if not specified */
  168.    waitfor_buffer = '' ; done = -1; curpos = 1
  169.    ORI_TIME=TIME('E')
  170.  
  171.    if (remain_buffer = 'REMAIN_BUFFER') then do
  172.       remain_buffer = ''
  173.    end
  174.  
  175.    do while (done = -1)
  176.       if (remain_buffer \= '') then do
  177.          line = remain_buffer
  178.          remain_buffer = ''
  179.        end
  180.        else do
  181.          line = slip_com_input(interface,,10)
  182.       end
  183.       waitfor_buffer = waitfor_buffer || line
  184.       index = pos(waitstring,waitfor_buffer)
  185.       if (index > 0) then do
  186.          remain_buffer = substr(waitfor_buffer,index+length(waitstring))
  187.          waitfor_buffer = delstr(waitfor_buffer,index+length(waitstring))
  188.          done = 0
  189.       end
  190.       call charout , substr(waitfor_buffer,curpos)
  191.       curpos = length(waitfor_buffer)+1
  192.       if ((done \= 0) & (TIME('E')>timeout)) then do
  193.         call lineout , ' WAITFOR: timed out '
  194.         done = 1
  195.        end
  196.    end
  197.    timeout=0
  198.    RC=done
  199.  return RC
  200.  
  201.  
  202.  
  203. /*--------------------------------------------------------------------------*/
  204. /*                               readpass ()                                */
  205. /*..........................................................................*/
  206. /*                                                                          */
  207. /* Routine used to read a password from the user without echoing the        */
  208. /* password to the screen.                                                  */
  209. /*                                                                          */
  210. /*--------------------------------------------------------------------------*/
  211.  
  212. readpass:
  213.  
  214.   answer = ''
  215.   do until key = cr
  216.     key = slip_getch()
  217.     if key \= cr then do
  218.       answer = answer || key
  219.     end
  220.   end
  221.   say ''
  222.   return answer
  223.  
  224.  
  225. /*--------------------------------------------------------------------------*/
  226. /*                             flush_receive ()                             */
  227. /*..........................................................................*/
  228. /*                                                                          */
  229. /* Routine to flush any pending characters to be read from the COM port.    */
  230. /* Reads everything it can until nothing new shows up for 100ms, at which   */
  231. /* point it returns.                                                        */
  232. /*                                                                          */
  233. /* The optional echo argument, if 1, says to echo flushed information.      */
  234. /*                                                                          */
  235. /*--------------------------------------------------------------------------*/
  236.  
  237. flush_receive:
  238.  
  239.    parse arg echo
  240.  
  241.    /* If echoing the flush - take care of waitfor remaining buffer */
  242.    if (echo \= '') & (length(remain_buffer) > 0) then do
  243.       call charout , remain_buffer
  244.       remain_buffer = ''
  245.    end
  246.  
  247.    /* Eat anything left in the modem or COM buffers */
  248.    /* Stop when nothing new appears for 100ms.      */
  249.  
  250.    do until line = ''
  251.      line = slip_com_input(interface,,100)
  252.      if echo \= '' then
  253.         call charout , line
  254.    end
  255.  
  256.    return
  257.  
  258.  
  259.  
  260. >>>>>>>>>>end slipnet.cmd>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
  261.  
  262.  
  263. ORIGIN:OS2SUP
  264.  
  265.