home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
OS/2 Shareware BBS: 35 Internet
/
35-Internet.zip
/
yccis.cmd
< prev
next >
Wrap
OS/2 REXX Batch file
|
1996-01-17
|
10KB
|
244 lines
/*--------------------------------------------------------------------------*/
/* */
/* OS/2 REXX Driver for OS/2 Warp (Connect or IAK+PPP update) */
/* */
/* YCCIS.CMD dialstr userid password */
/* */
/* .................................................. */
/* */
/* Attachment script for dialing into CIS via PPP. */
/* */
/* The script sends the dial string to the modem and then logs into the */
/* terminal server using the userid/password. It solves the problem */
/* of dialling at 7-bit even parity, and connecting at 8-bit no parity */
/* */
/* Note: this script sets up hardware flow control on the COM port. */
/* Ensure your modem setup also sets up hardware flow control. */
/* (Ignore all recommendations for XON/XOFF flow control - it won't work). */
/* */
/* Usage: Copy this command file (YCCIS.CMD) to \TCPIP\BIN. */
/* Customize the string assigned to mdm_str for your modem. */
/* Enter <YCCIS.CMD ATDTnnn userid password> as your login sequence */
/* and ensure that there are no blank lines following that line!!! */
/* */
/* Author: Mark Yudkin 76251.3362@compuserve.com */
/* (C) Mark Yudkin, 1995 */
/* */
/* Email me for information on Cogent/SQLfor OS/2 and Cogent/SQL for MVS */
/* the leading code generator authoring tool for OS/2 and/or MVS. */
/*--------------------------------------------------------------------------*/
/* first 3 parameters are from dialler (ignore 3rd), next 3 from user: */
parse arg interface, comport, , dialcmd, userid, password
/*--------------------------------------------------------------------------*/
/* Initialization and Main Script Code */
/*--------------------------------------------------------------------------*/
/* Set fixed values - customize as necessary (use hardware flow control) */
mdm_str = 'ATE0Q0S0=0V1X1&C1&D2&N17&S1&G2&K3' /* for Zyxel U-1496E */
/* the rest of the script does not need any customization */
/* Set some definitions for easier COM strings */
cr='0d'x
crlf='0d0a'x
say ''
say 'COMPUSERVE - PPP Server Connection Script (C) Mark Yudkin, 1995',
'(interface' interface') on' comport
/* Prompt for missing information */
if dialcmd = '' then do
call charout , 'Dial Command: '
parse pull dialcmd
end
if userid = '' | userid = '*' then do
call charout , 'User Name: '
parse pull userid
end
else do
say 'User:' userid
end
if password = '' | password = '*' then do
call charout , 'Password: '
password = readpass()
end
/* Flush any stuff left over from previous COM activity */
call flush_receive
/* Reset and initialize the modem here */
call lineout, 'Initializing' comport 'for login...'
/* "MODE" comport "57600,E,7,1,IDSR=OFF,OCTS=ON,RTS=ON,ODSR=OFF,DTR=ON,XON=OFF,BUFFER=AUTO" */
"MODE" comport "57600,E,7,1,IDSR=OFF,OCTS=ON,RTS=HS,ODSR=OFF,DTR=ON,XON=OFF,BUFFER=AUTO"
call lineout, 'Resetting and initializing modem...'
call send 'AT&F' || cr
call waitfor 'OK'; call flush_receive 'echo'
if RC = 1 then do
call lineout , 'Modem not resetting... Trying again'
call send '+++'
call waitfor 'OK'
call send 'ATHZ' || cr
call waitfor 'OK'
end
call send mdm_str || cr
call waitfor 'OK'; call flush_receive 'echo'
/* Dial the remote server */
call charout , 'Dialing...' || crlf
/* Wait for connection */
call send dialcmd || cr
call waitfor 'CONNECT' ; call waitfor crlf
/* Handle login. We wait for standard strings, and then flush anything */
/* else to take care of trailing spaces, etc.. */
call send cr
call waitfor 'ame:' ; call flush_receive 'echo'
call send 'CIS' || cr
call waitfor 'ID:' ; call flush_receive 'echo'
call send userid || '/GO:PPPCONNECT' || cr
call waitfor 'ord:' ; call flush_receive 'echo'
call send password || cr
/* Wait for the main prompt and then send the "ppp" command */
call waitfor 'PPP' ; call flush_receive 'echo'
call send 'PPP' || cr
/* Flush anything else */
call flush_receive 'echo'
/* reset the serial port for PPP */
call lineout , 'Resetting' comport 'for PPP...'
"MODE" comport "57600,N,8,1,BUFFER=AUTO"
say 'PPP Connection Established'
/* All done */
exit 0
/*--------------------------------------------------------------------------*/
/* send ( sendstring) */
/*..........................................................................*/
/* */
/* Routine to send a character string off to the modem. */
/* */
/*--------------------------------------------------------------------------*/
send:
parse arg sendstring
call ppp_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 = ppp_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 = SysGetKey('NOECHO')
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 = ppp_com_input(interface,,100)
if echo \= '' then
call charout , line
end
return