home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
OS/2 Shareware BBS: 35 Internet
/
35-Internet.zip
/
pcnet.cmd
< prev
next >
Wrap
OS/2 REXX Batch file
|
1995-01-07
|
14KB
|
304 lines
/*--------------------------------------------------------------------------*/
/* modified by prs on 05/19/94 */
/* modified by emr on 12/1/94 */
/* */
/* */
/* OS/2 2.0 SLIP Driver for IBM TCP/IP version 2.0 */
/* modified to fit the Warp TCP/IP implementation */
/* */
/* SLIPUP.CMD */
/* */
/* .................................................. */
/* */
/* Sample attachment script for dialing into the PCNet terminal */
/* server in order to establish a SLIP connection. This script should be */
/* specified using the "attachcmd" and "attachparm" elements in the SLIP */
/* configuration file SLIP.CFG. For example: */
/* */
/* interface sl0 { */
/* attachcmd = slipup */
/* attachparm = "dialcmd username password" */
/* } */
/* */
/* Instead of linking into the SLIP.CFG file in Warp, this links into */
/* the Provider dialog in SLIPPM.EXE. Specify the script in the Login */
/* scriptbox in screen 1 of 4 of Modify Provider/Provider Information */
/* in the Dial Other Internet Providers Screen: */
/* */
/* paradigm.com <dial command> <userid> <password> */
/* */
/* For example: paradigm.cmd atdt2501205 Puserid MyPassWd */
/* */
/* The script parameters specify the command to send to the modem to dial */
/* the remote site and the username/password combination to use to log into */
/* the terminal server. If any of the parameters are omitted, or are */
/* specified as an asterix (*), the script will prompt for them. This is */
/* most useful with the password parameter to avoid storing the password */
/* in a text file on the disk. */
/* */
/* For example, the following might be how I would set it up: */
/* */
/* interface sl0 { */
/* attachcmd = slipup */
/* attachparm = "atdt###-#### db3l *" */
/* } */
/* */
/* which would cause slipup to initially prompt me for the password. It */
/* would then feed the "atdt###-####" command to the modem, and when the */
/* pcnet answered, it would use "db3l" as a username and the password I */
/* initially entered as the password. */
/* */
/* - - - - - - - - - - - - - - - - - - - - - - - - - */
/* --emr 12/1/94 */
/* 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. The interface info is taken from page 4 of 4 of the SLIPPM */
/* Modify Provider dialog */
/* */
/* The script sends the dial string to the modem and then logs into the */
/* terminal server using the username/password. It then issues the SLIP */
/* command to start SLIP, and parses the resulting output to determine the */
/* appropriate addresses to use. Lastly, it issues ifconfig and route */
/* commands to configure the OS/2 system appropriately. Note that the */
/* configuration assumes a class C netmask for the SLIP interface. */
/* */
/* -- emr 12/7/94 */
/* Actually, rpinz has the SLIP or PPP command set up to run automagically */
/* on my account, so no SLIP command is issued by the script. It would be */
/* given at the noted location in this script */
/*--------------------------------------------------------------------------*/
parse arg interface , dialcmd username password
/*--------------------------------------------------------------------------*/
/* Initialization and Main Script Code */
/*--------------------------------------------------------------------------*/
/* Set some definitions for easier COM strings */
cr='0d'x
crlf='0d0a'x
ctrlc='03'x
say ''
say 'SLIPUP - SLIP Script ',
'(interface' interface')'
/* Prompt for missing information */
if dialcmd = '' then do
call charout , 'Dial Command: '
parse pull dialcmd
end
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
/* Reset comport settings */
/* emr - commented out in the Warp version */
/* MODE "COM2: 19200,n,8,1,buffer=on,rts=hs" */
/* Initialize modem */
/* Reset the modem here */
/* You may need to customize this for your modem make and model */
/* emr - This is set up for a USR Sportster v.34 connecting at 14.4K */
call lineout , 'Reset modem...'
call send 'AT&F1&A3&K3' || cr
call waitfor 'OK', 5 ; 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', 3
end
/* Flush any stuff left over from previous COM activity */
call flush_receive
/* Dial the remote server */
call charout , 'Now Dialing...'
/* 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 'login:' ; call flush_receive 'echo'
call send username || cr
call waitfor 'Password:' ; call flush_receive 'echo'
call send password || cr
/* --emr 12/7/94 */
/* Add the necessary call to waitfor and send as noted here */
/* Uncomment if necessary */
/* call waitfor 'Net%' ; call flush_receive 'echo' */
/* call send 'slip' || cr */
/* Parse the results of the SLIP command to determine our address. */
/* We use the "waitfor_buffer" variable from the waitfor routine */
/* to parse the stuff we get from PCNET after waiting for an */
/* appropriate point in the data stream. */
call waitfor 'beginning....'
/* --emr 12/1/94 */
/* The following picks up the necessary detail for my account, but */
/* since PPP isn't supported, the connection breaks quickly. I */
/* assume that Ron can set up SL/IP, and that the prompt string */
/* would change to "SL/IP" rather than "PPP" below */
/* */
parse var waitfor_buffer . 'SL/IP session from (' a '.' b '.' c '.' d ') to ' e '.' f '.' g '.' h .
pcnet_address = a||'.'||b||'.'||c||'.'||d
os2_address = e||'.'||f||'.'||g||'.'||h
/* Flush anything else */
call flush_receive 'echo'
/* Now configure this host for the appropriate address, */
/* and for a default route through the pcnet. */
say ' '
say 'SLIP Connection Established'
say 'Configuring local address =' os2_address ', PCNet =' pcnet_address
'ifconfig sl0' os2_address pcnet_address 'netmask 255.255.255.0'
'route add default' pcnet_address '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