home *** CD-ROM | disk | FTP | other *** search
/ OS/2 Shareware BBS: 18 REXX / 18-REXX.zip / rexxppp.zip / mindspr.cmd < prev    next >
OS/2 REXX Batch file  |  1996-09-16  |  3KB  |  136 lines

  1. /* mindspr.cmd */
  2.  
  3.  parse arg interface ,
  4.  
  5.  cr='0d'x
  6.  crlf='0d0a'x
  7.  
  8.  /* REPLACE WITH YOUR ACCOUNT INFO */
  9.  login='userid'
  10.  pass='password'
  11.  phone='atdt4043350600'
  12.  
  13.  /* CHANGE TO MATCH YOUR MODEM SETTINGS */
  14.  /* Note:  you may only need to change the ComPort */
  15.  ComPort='COM2'
  16.  ModeOptions='57600,n,8,1,rts=hs,octs=on,dtr=on,buffer=on'
  17.  /* You need Ray Gwinn's SIO Drivers to run at 115200 bps */
  18.  
  19.  say ''
  20.  say 'MindSpring PPP Connection Script ',
  21.      '(interface' interface')'
  22.  
  23.  'mode 'ComPort||': ' ModeOptions
  24.  call flush_receive
  25.  call lineout , 'Reset modem...'
  26.  
  27.  /* Change to match your modem settings */
  28.  /*  DOESNT WORK call send 'AT&F1S37=29S109=768' || cr */
  29.  call send 'ATZ' || cr
  30.  call waitfor 'OK', 5 ; call flush_receive 'echo'
  31.  /* ------------------------------- */
  32.  
  33.   if RC = 1 then do
  34.      call lineout , 'Modem not resetting... Trying again'
  35.      call send '```'
  36.      call waitfor 'OK'
  37.      call send 'ATHZ' || cr
  38.      call waitfor 'OK', 3
  39.    end
  40.  
  41.  /* CHANGE HERE FOR A DIFFERENT LOGIN SEQUENCE */
  42.  call charout , 'Now Dialing...'
  43.  call send phone || cr
  44.  call waitfor 'ogin:' ; call flush_receive 'echo'
  45.  call send login || cr
  46.  call waitfor 'assword:' ; call flush_receive 'echo'
  47.  call send pass || crlf
  48.  call lineout , ' '
  49.  say 'LOGIN COMPLETED'
  50.  
  51.  
  52.  /* All done */
  53.  exit 0
  54.  
  55.  send:
  56.  
  57.     parse arg sendstring
  58.     call ppp_com_output interface , sendstring
  59.  
  60.     return
  61.  
  62.  
  63.  waitfor:
  64.  
  65.     parse arg waitstring , timeout
  66.  
  67.     if timeout = '' then
  68.       timeout = 5000    /* L O N G   delay if not specified */
  69.     waitfor_buffer = '' ; done = -1; curpos = 1
  70.     ORI_TIME=TIME('E')
  71.  
  72.     if (remain_buffer = 'REMAIN_BUFFER') then do
  73.        remain_buffer = ''
  74.     end
  75.  
  76.     do while (done = -1)
  77.        if (remain_buffer \= '') then do
  78.           line = remain_buffer
  79.           remain_buffer = ''
  80.         end
  81.         else do
  82.           line = ppp_com_input(interface,,10)
  83.        end
  84.        waitfor_buffer = waitfor_buffer || line
  85.        index = pos(waitstring,waitfor_buffer)
  86.        if (index > 0) then do
  87.           remain_buffer = substr(waitfor_buffer,index+length(waitstring))
  88.           waitfor_buffer = delstr(waitfor_buffer,index+length(waitstring))
  89.           done = 0
  90.        end
  91.        call charout , substr(waitfor_buffer,curpos)
  92.        curpos = length(waitfor_buffer)+1
  93.        if ((done \= 0) & (TIME('E')>timeout)) then do
  94.          call lineout , ' WAITFOR: timed out '
  95.          done = 1
  96.         end
  97.     end
  98.     timeout=0
  99.     RC=done
  100.   return RC
  101.  
  102.  readpass:
  103.  
  104.    answer = ''
  105.    do until key = cr
  106.      key = ppp_getch()
  107.      if key \= cr then do
  108.        answer = answer || key
  109.      end
  110.    end
  111.    say ''
  112.    return answer
  113.  
  114.  flush_receive:
  115.  
  116.     parse arg echo
  117.  
  118.     /* If echoing the flush - take care of waitfor remaining buffer */
  119.     if (echo \= '') & (length(remain_buffer) > 0) then do
  120.        call charout , remain_buffer
  121.        remain_buffer = ''
  122.     end
  123.  
  124.     /* Eat anything left in the modem or COM buffers */
  125.     /* Stop when nothing new appears for 100ms.      */
  126.  
  127.     do until line = ''
  128.       line = ppp_com_input(interface,,100)
  129.       if echo \= '' then
  130.          call charout , line
  131.     end
  132.  
  133.     return
  134.  
  135.  
  136.