home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
OS/2 Shareware BBS: 29 Fixes_o
/
29-Fixes_o.zip
/
tcpcsd2.zip
/
BASECSD2.EXE
/
BIN
/
AUTOANS.CMD
< prev
next >
Wrap
OS/2 REXX Batch file
|
1993-07-12
|
8KB
|
197 lines
/*--------------------------------------------------------------------------*/
/* */
/* OS/2 2.0 SLIP Driver for IBM TCP/IP version 2.0 */
/* */
/* AUTOANS.CMD */
/* */
/* .................................................. */
/* */
/* Sample attachment script for putting the modem in auto answer mode for */
/* others to dial into this machine. This script should be specified using */
/* the "attachcmd" and "attachparm" elements in the SLIP.CFG file. */
/* For example: */
/* */
/* interface sl0 { */
/* attachcmd = autoans */
/* } */
/* */
/* */
/* When the script runs, it is automatically passed the interface name for */
/* the interface it is running on as the first argument, and the user */
/* arguments (from SLIP.CFG) as the second argument. */
/* */
/*--------------------------------------------------------------------------*/
parse arg interface , comport baud
/* Setup modem for autoanswer mode */
/* check for input arg (slip interface for now) */
/* Set some definitions for easier COM strings */
cr='0d'x
crlf='0d0a'x
reset='ATZ' /* Reset command to send to modem */
anscmd='ATS0=2S95=45S7=30' /* Pickup after x ring(s) */
/* check input args and take default if not specified in SLIP.CFG */
if interface='' | interface='*' then do
call lineout , ' AUTOANS: INTERFACE not specified. Default SL0 '
interface='sl0'
end
if comport= '' | comport='*' then do
call lineout , ' AUTOANS: COM Port was not specified. Default COM1 '
comport='COM1'
end
if baud='' | baud='*' then do
call lineout , ' AUTOANS: BAUD was not specified. Default 1200 '
baud='1200'
end
/* Setup TCPIP info for this machine */
call lineout , ' AUTOANS: Setting up TCPIP info for this machine ...'
'arp -f'
'ifconfig ' interface' 222.222.222.10 222.222.222.20 netmask 255.255.255.0'
'route -fh add default 222.222.222.20 1'
/* Setup COM Port */
call lineout , ' AUTOANS: COM Port settings: mode 'comport baud',n,8,1'
'mode 'comport baud',n,8,1,BUFFER=ON'
/*--------------------------------------------------------------------------*/
/*--------------------------------------------------------------------------*/
/* Initialization and Main Script Code */
/*--------------------------------------------------------------------------*/
/* Flush any stuff left over from previous COM activity */
call flush_receive
/* Reset & put modem in Auto Answer mode */
call send reset || cr
call waitfor 'OK'
call send anscmd || cr
call waitfor 'OK' ; call flush_receive 'echo'
/* Setup All done, returning control to SLIP */
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. */
/* */
/*--------------------------------------------------------------------------*/
waitfor:
parse arg waitstring , timeout
waitfor_buffer = '' ; done = 0 ; curpos = 1
if (remain_buffer = 'REMAIN_BUFFER') then do
remain_buffer = ''
end
do while done = 0
if (remain_buffer \= '') then do
line = remain_buffer
remain_buffer = ''
end
else do
line = slip_com_input(interface)
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 = 1
end
call charout , substr(waitfor_buffer,curpos)
curpos = length(waitfor_buffer)+1
end
return
/*--------------------------------------------------------------------------*/
/* 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