home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
OS/2 Shareware BBS: 35 Internet
/
35-Internet.zip
/
ccsoslip.zip
/
CCSOSLIP.CMD
next >
Wrap
OS/2 REXX Batch file
|
1995-09-06
|
9KB
|
241 lines
/*--------------------------------------------------------------------------*/
/* */
/* OS/2 2.1 / WARP REXX SL/IP Dialup Script for Dynamic IP Addresses */
/* (modified from original IBM script for UIUC CCSO Terminal Server) */
/* m-woo@uiuc.edu, 6 September 1995 */
/* member of Champaign-Urbana OS/2 Users Group */
/* in no way affiliated with UIUC CCSO */
/*--------------------------------------------------------------------------*/
/* Loading the REXXUtils DLLs -- okay, they hog resources, but... */
call RxFuncAdd "SysSleep", "RexxUtil", "SysSleep"
/* If you are having trouble with your modem not hanging up, try */
/* uncommenting or adding the appropriate MODE command below */
/* 'mode com1,,,,,dtr=on' */
/* 'mode com2,,,,,dtr=on' */
/* Okay, I shouldn't have hardcoded the terminal server's phone number here */
/* -- feel free to change it to an argument */
/* Normal CCSO terminal server phone number */
dialcmd = 'atdt333-3700'
/* CCSO 28.8 kbps dialup phone number */
/* dialcmd = 'atdt244-5109' */
/* CCSO Faculty and Staff phone number */
/* dialcmd = 'atdt333-7999' */
parse arg interface , username password
/*--------------------------------------------------------------------------*/
/* Initialization and Main Script Code */
/*--------------------------------------------------------------------------*/
cr='0d'x
crlf='0d0a'x
say ''
say 'CCSO Terminal Server SLIP Connection Script ',
'(interface' interface')'
if username = '' | username = '*' then do
call charout , 'User Name: '
parse pull username
end
else do
say 'User:' username
end
if password = '' | password = '*' then do
call charout , 'Password: '
password = readpass()
end
call flush_receive
call lineout , 'Reset modem...'
call send 'ATZ' || cr
call waitfor 'OK', 5 ; call flush_receive 'echo'
call SysSleep 5
if RC = 1 then do
call lineout , 'Modem not resetting... Trying again'
call send '+++'
call waitfor 'OK'
call send 'ATHZ' || cr
call waitfor 'OK', 3
end
call charout , 'Now Dialing...'
/* Wait for connection - will redial if not online */
/* Note: redial doesn't seem to work with the new IAK dialer :-( */
call lineout , ' ...Dialing CCSO Terminal Server...'
connected = '0'
do forever until connected
call send dialcmd || cr
call waitfor 'CONNECT', 30
if pos('CONNECT',waitfor_buffer) \=0 then do
call lineout , ' ...Connected to CCSO Terminal Server'
connected = '1'
call waitfor crlf
end
call SysSleep 5
end
/* Handle login. We wait for standard strings, and then flush anything */
/* else to take care of trailing spaces, etc.. */
call waitfor 'Username:' ; call flush_receive 'echo'
call send username || cr
call waitfor 'Password:' ; call flush_receive 'echo'
call send password || cr
call waitfor '>' ; call flush_receive 'echo'
call send 'SLIP default' || cr
call waitfor 'Your IP address is '
call waitfor '. MTU'
/* Flush anything else */
call flush_receive 'echo'
'detach bootp sl0'
/* The next line is a strange kludge that shouldn't be needed, */
/* but for some reason my system won't work without it */
/* Depending on what CCSO does, the address may have to be */
/* changed in the future */
/* If you are having trouble, you might try using it */
/* 'route add default 128.174.22.9 1' */
/* All done */
exit 0
/*--------------------------------------------------------------------------*/
/* send ( sendstring) */
/*..........................................................................*/
/* */
/* Routine to send a character string off to the modem. */
/* */
/*--------------------------------------------------------------------------*/
send:
parse arg sendstring
call slip_com_output interface , sendstring
return
/*--------------------------------------------------------------------------*/
/* waitfor ( waitstring , [timeout] ) */
/*..........................................................................*/
/* */
/* Waits for the supplied string to show up in the COM input. All input */
/* from the time this function is called until the string shows up in the */
/* input is accumulated in the "waitfor_buffer" variable. */
/* */
/* If timeout is specified, it says how long to wait if data stops showing */
/* up on the COM port (in seconds). */
/* */
/*--------------------------------------------------------------------------*/
waitfor:
parse arg waitstring , timeout
if timeout = '' then
timeout = 5000 /* L O N G delay if not specified */
waitfor_buffer = '' ; done = -1; curpos = 1
ORI_TIME=TIME('E')
if (remain_buffer = 'REMAIN_BUFFER') then do
remain_buffer = ''
end
do while (done = -1)
if (remain_buffer \= '') then do
line = remain_buffer
remain_buffer = ''
end
else do
line = slip_com_input(interface,,10)
end
waitfor_buffer = waitfor_buffer || line
index = pos(waitstring,waitfor_buffer)
if (index > 0) then do
remain_buffer = substr(waitfor_buffer,index+length(waitstring))
waitfor_buffer = delstr(waitfor_buffer,index+length(waitstring))
done = 0
end
call charout , substr(waitfor_buffer,curpos)
curpos = length(waitfor_buffer)+1
if ((done \= 0) & (TIME('E')>timeout)) then do
call lineout , ' WAITFOR: timed out '
done = 1
end
end
timeout=0
RC=done
return RC
/*--------------------------------------------------------------------------*/
/* readpass () */
/*..........................................................................*/
/* */
/* Routine used to read a password from the user without echoing the */
/* password to the screen. */
/* */
/*--------------------------------------------------------------------------*/
readpass:
answer = ''
do until key = cr
key = slip_getch()
if key \= cr then do
answer = answer || key
end
end
say ''
return answer
/*--------------------------------------------------------------------------*/
/* flush_receive () */
/*..........................................................................*/
/* */
/* Routine to flush any pending characters to be read from the COM port. */
/* Reads everything it can until nothing new shows up for 100ms, at which */
/* point it returns. */
/* */
/* The optional echo argument, if 1, says to echo flushed information. */
/* */
/*--------------------------------------------------------------------------*/
flush_receive:
parse arg echo
/* If echoing the flush - take care of waitfor remaining buffer */
if (echo \= '') & (length(remain_buffer) > 0) then do
call charout , remain_buffer
remain_buffer = ''
end
/* Eat anything left in the modem or COM buffers */
/* Stop when nothing new appears for 100ms. */
do until line = ''
line = slip_com_input(interface,,100)
if echo \= '' then
call charout , line
end
return