home *** CD-ROM | disk | FTP | other *** search
/ OS/2 Shareware BBS: 35 Internet / 35-Internet.zip / crswrp.zip / LOGNCRIS.CMD < prev   
OS/2 REXX Batch file  |  1994-11-28  |  7KB  |  215 lines

  1. /*--------------------------------------------------------------------------*/
  2. /*        OS/2 2.1 / WARP REX Driver for IBM TCP/IP version 2.0 / IAK       */
  3. /*                                                                          */
  4. /*                            LOGNCRIS.CMD                                  */
  5. /*                                                                          */
  6. /*            ..................................................            */
  7. /*                                                                          */
  8. /* Sample attachment script for dialing into a CRIS Point of Presence       */
  9. /* server in order to establish a SLIP connection.  This script should be   */
  10. /* specified on page 1 in the Login Script field for connections via SlipPM */
  11. /*                                                                          */
  12. /*       YOU WILL NEED THE FOLLOWING FOR YOUR ADD PROVIDER CHANGES          */
  13. /*       Login Script: logncris.cmd 999-9999 loginid@SLIP password          */
  14. /*                                                                          */
  15. /* which would then feed the "999-9999" command to the modem, followed      */
  16. /* by the login id and password once the connection is established.         */
  17. /*--------------------------------------------------------------------------*/
  18.  
  19.  
  20. /*--------------------------------------------------------------------------*/
  21. /*                   Initialization and Main Script Code                    */
  22. /*--------------------------------------------------------------------------*/
  23.  
  24. parse arg interface , dialcmd username password
  25.  
  26. cr='0d'x
  27. crlf='0d0a'x
  28. call RxFuncAdd 'SysSleep', 'RexxUtil', 'SysSleep'
  29. 'mode.com COM2,,,,,,DTR=ON'
  30.  
  31. /*--------------------------------------------------------------------------*/
  32.  
  33. say ''
  34. say 'CRIS SLIP Connection Script ' , 
  35. '(interface' interface')'
  36. say 'Resetting Modem'
  37. say 'Now Dialing...'
  38. phoneresult = 2
  39. trys = 1
  40.  
  41. do while trys < 5 & phoneresult > 1
  42.  call placecall
  43. end
  44.  
  45. if phoneresult > 1
  46.  then
  47.  exit 99
  48.   
  49.   call send '@D' || cr
  50.   call waitfor 'user:' ; call flush_receive 'echo'
  51.   call send username || cr
  52.   call waitfor 'Password:' ; call flush_receive 'echo'
  53.   call send password || cr
  54.   call flush_receive 'echo'
  55.   say 'SLIP Connection Established'
  56.   cris_address = 192.0.2.1
  57.   os2_address = 199.3.12.9
  58.   say 'Configuring local address =' os2_address
  59.   'ifconfig sl0' os2_address cris_address 'netmask 255.255.255.0'
  60.   'route add default' cris_address '1'
  61.  
  62.  exit 0
  63.  
  64. /*--------------------------------------------------------------------------*/
  65.  
  66. send:
  67.  
  68.    parse arg sendstring
  69.    call slip_com_output interface , sendstring
  70.  
  71.    return
  72.  
  73. /*--------------------------------------------------------------------------*/
  74.  
  75. placecall:
  76.  say 'Try #' trys
  77.  say 'No Connection Yet'
  78.  call mdmreset
  79.  call send 'atdt' dialcmd || cr
  80.  call waitfor3 'ARQ', 'BUSY' , 'NO CARRIER' ; call waitfor crlf
  81.  phoneresult = stringchosen
  82.  trys = trys + 1
  83.  call flush_receive ''
  84. return
  85.  
  86. /*--------------------------------------------------------------------------*/
  87.  
  88. waitfor:
  89.  
  90.    parse arg waitstring , timeout
  91.  
  92.    if timeout = '' then
  93.      timeout = 5000    /* L O N G   delay if not specified */
  94.    waitfor_buffer = '' ; done = -1; curpos = 1
  95.    ORI_TIME=TIME('E')
  96.  
  97.    if (remain_buffer = 'REMAIN_BUFFER') then do
  98.       remain_buffer = ''
  99.    end
  100.  
  101.    do while (done = -1)
  102.       if (remain_buffer \= '') then do
  103.          line = remain_buffer
  104.          remain_buffer = ''
  105.        end
  106.        else do
  107.          line = slip_com_input(interface,,10)
  108.       end
  109.       waitfor_buffer = waitfor_buffer || line
  110.       index = pos(waitstring,waitfor_buffer)
  111.       if (index > 0) then do
  112.          remain_buffer = substr(waitfor_buffer,index+length(waitstring))
  113.          waitfor_buffer = delstr(waitfor_buffer,index+length(waitstring))
  114.          done = 0
  115.       end
  116.       call charout , substr(waitfor_buffer,curpos)
  117.       curpos = length(waitfor_buffer)+1
  118.       if ((done \= 0) & (TIME('E')>timeout)) then do
  119.         call lineout , ' WAITFOR: timed out '
  120.         done = 1
  121.        end
  122.    end
  123.    timeout=0
  124.    RC=done
  125.  return RC
  126.  
  127. /*--------------------------------------------------------------------------*/
  128.  
  129. mdmreset:
  130.  
  131. call SysSleep 2
  132. call flush_receive ''
  133. call send 'AT&F' || cr
  134. call waitfor 'OK', 5 ; call flush_receive ''
  135. call send 'ATHZ0' || cr
  136. call waitfor 'OK', 5 ; call flush_receive ''
  137.  if RC = 1 then do
  138.     call lineout , 'Modem not resetting... Trying again'
  139.     call send '+++'
  140.     call waitfor 'OK'
  141.     call send 'ATHZ' || cr
  142.     call waitfor 'OK', 3
  143.   end
  144.  
  145. return
  146.  
  147. /*--------------------------------------------------------------------------*/
  148.  
  149. flush_receive:
  150.  
  151.    parse arg echo
  152.  
  153.    if (echo \= '') & (length(remain_buffer) > 0) then do
  154.       call charout , remain_buffer
  155.       remain_buffer = ''
  156.    end
  157.  
  158.    do until line = ''
  159.      line = slip_com_input(interface,,100)
  160.      if echo \= '' then
  161.         call charout , line
  162.    end
  163.  
  164.    return
  165.    
  166. /*--------------------------------------------------------------------------*/
  167.  
  168. waitfor3:
  169.  
  170.    parse arg waitstring1 , waitstring2 , waitstring3 , timeout
  171.    waitfor_buffer = '' ; done = 0 ; curpos = 1
  172.    if (remain_buffer = 'REMAIN_BUFFER') then do
  173.       remain_buffer = ''
  174.    end
  175.    do while done = 0
  176.       if (remain_buffer \= '') then do
  177.          line = remain_buffer
  178.      remain_buffer = ''
  179.       end
  180.       else do
  181.          line = slip_com_input(interface)
  182.       end
  183.       waitfor_buffer = waitfor_buffer || line
  184.       index1 = pos(waitstring1,waitfor_buffer)
  185.       index2 = pos(waitstring2,waitfor_buffer)
  186.       index3 = pos(waitstring3,waitfor_buffer)
  187.       if (index1 > 0) then do
  188.          remain_buffer = substr(waitfor_buffer,index1+length(waitstring1))
  189.      waitfor_buffer = delstr(waitfor_buffer,index1+length(waitstring1))
  190.          stringchosen = 1
  191.          done = 1
  192.       end
  193.       else do
  194.     if (index2 > 0) then do
  195.         remain_buffer = substr(waitfor_buffer,index2+length(waitstring2))
  196.         waitfor_buffer = delstr(waitfor_buffer,index2+length(waitstring2))
  197.         stringchosen = 2
  198.         done = 1
  199.     end
  200.     else do
  201.         if (index3 > 0) then do
  202.         remain_buffer = substr(waitfor_buffer,index3+length(waitstring3))
  203.         waitfor_buffer = delstr(waitfor_buffer,index3+length(waitstring3))
  204.         stringchosen = 3
  205.         done = 1    
  206.         end
  207.     end
  208.       end
  209.  
  210.       call charout , substr(waitfor_buffer,curpos)
  211.       curpos = length(waitfor_buffer)+1
  212.     end
  213.  
  214.   return
  215.