home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
The Pier Shareware 6
/
The_Pier_Shareware_Number_6_(The_Pier_Exchange)_(1995).iso
/
035
/
ccniak.zip
/
HOOKED2.CMD
< prev
Wrap
OS/2 REXX Batch file
|
1994-11-23
|
13KB
|
310 lines
/*--------------------------------------------------------------------------*/
/* HOOKED2.CMD */
/* 11-15-94 */
/* Customized by Chacko Neroth (address: cheroth@hooked.net) */
/* */
/* OS/2 2.1 / WARP REX Driver for IBM TCP/IP version 2.0 / IAK */
/* */
/* */
/* Sample attachment script for dialing to hooked.net (TIA)internet provider*/
/* in order to establish a SLIP connection via TIA. This script should be */
/* specified on page 1 in the Login Script field for connections via SlipPM */
/* or using the -connect option if executing slip directly. */
/* */
/* NOTE: This file is supplied as a sample connection script, and */
/* does not constitute the endorsement of a particular */
/* Internet provider on the part of IBM. */
/* Internet providers periodically change their connection */
/* procedures; please refer to the latest information provided */
/* by the service provider. */
/* */
/* This script may be modified to suit the needs of the user */
/* and is written to process dialogs similar to those */
/* used by TIA SLIP type service providers. */
/* */
/* 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 (Refer */
/* to caveate below). 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 used in SlipPM: */
/* Login Script: hooked.cmd atdt999-9999 loginid password */
/* */
/* which would then feed the "atdt999-9999" command to the modem, followed */
/* by the login id and password once the connection is established. */
/* */
/* From slip directly the hooked script supports: */
/* -connect "hooked.cmd atdt999-9999 loginid *" */
/* */
/* which would cause hooked.cmd to initially prompt for the password. It */
/* would then feed the "atdt999-9999" command to the modem, and when */
/* Hooked answered, it would use "loginid" as a username and the password */
/* specified. */
/* */
/* NOTE: You must pass the phone number, and both login id and password */
/* to hooked.cmd from the Dialer. The Dialer will NOT allow for the */
/* input of a phone number, login or password from the keyboard. */
/* - - - - - - - - - - - - - - - - - - - - - - - - - */
/* */
/* When the script runs, it is automatically passed the interface name for */
/* the interface it is running on as the first argument, followed by the */
/* user arguments. */
/* */
/* 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. Lastly, it issues ifconfig and route */
/* commands to configure the OS/2 system appropriately. Note that the */
/* configuration uses the hooked netmask for the SLIP interface. */
/* */
/*--------------------------------------------------------------------------*/
parse arg interface , dialcmd username password
/*--------------------------------------------------------------------------*/
/* Initialization and Main Script Code */
/*--------------------------------------------------------------------------*/
/* Set some definitions for easier COM strings */
cr='0d'x
crlf='0d0a'x
/*say 'HOOKED -- Script for SLIP Dialer via TIA ('interface')'*/
dialcmd = 'ATL0DT534-0841' /* MODIFY FOR YOUR TEL ACCESS NUMBER */
/* change L0 to M0 to turn speaker off */
hostprompt= '>' /* MODIFY FOR YOUR HOST'S PROMT */
username= 'loginname' /* MODIFY FOR YOUR LOGIN_NAME */
password= 'password' /* MODIFY FOR YOUR PASSWORD */
'mode com2:dtr=on' /* needed with some com drivers */
/* Flush any stuff left over from previous COM activity */
call flush_receive
/* Reset the modem here */
/* You may need to customize this for your modem make and model */
/*call lineout , 'Reset modem...'*/
call send 'AT&F' || cr /* MODIFY IF NEEDED */
retry:
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
/* Dial the remote server */
call SysSleep(1)
call charout , 'Now Dialing...'
call send dialcmd || cr
/* Wait for connection */
RC = waitfor('CONNECT', 65); /*call flush_receive 'echo'*/
if (RC > 1) then /*busy*/
do
say 'BUSY, Retrying'
call send 'ATZ' || cr
call SysSleep(3)
signal retry
end
if (RC > 0) then /*timedout*/
do
say 'Connect: TIMED OUT'
exit 1
end
/*call waitfor crlf*/
relogc = 0
call waitfor 'login:',20 ; call flush_receive 'echo'
relog:
call SysSleep(1)
call send username || cr
call waitfor 'sword:',10 ; call flush_receive 'echo'
if (RC>0) then
do
relogc = relogc+1
if (relogc < 6) then
do
say 'Login/Password waiting timed out. Trying to relogin'
signal relog
end
else
do
say 'Login failed. Try again.'
exit 1
end
end
call SysSleep(1)
call send password || cr
call waitfor 'TERM=',5 ; call flush_receive 'echo'
call SysSleep(1)
call send cr
call waitfor hostprompt ; call flush_receive 'echo'
call send '/usr/local/bin/tia' || cr /* MODIFY THE PATH FOR YOUR PROVIDER*/
call waitfor 'software.' ; call flush_receive 'echo'
say 'SLIP Connection Established'
/* slip configuration with the hooked specific fixed ip */
ip = '199.2.134.2' /* MODIFY FOR YOUR PROVIDER's IP ADDRESS if not Hooked */
os2_address = ip
hooked_address = ip
netmask = '0.0.0.0' /* MODIFY FOR YOUR PROVIDER's MASK ADDRESS if not Hooked */
say 'Configuring local address =' os2_address ', Hooked =' hooked_address
'ifconfig sl0' ip ip 'netmask' netmask
'route add default' hooked_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
done = -1
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('BUSY',waitfor_buffer)
if (index > 0) then do
RC = 2
return RC
end
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