home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
OS/2 Shareware BBS: 35 Internet
/
35-Internet.zip
/
telepo.cmd
< prev
next >
Wrap
OS/2 REXX Batch file
|
1994-12-13
|
15KB
|
346 lines
/*--------------------------------------------------------------------------*/
/* */
/* OS/2 3.0 / WARP REX Driver for IBM TCP/IP version 2.0 / IAK */
/* */
/* FILE: teleport.cmd */
/* PURPOSE: Slip connect script for Teleport */
/* */
/* This script is used by the 'other Provider' connection program to dial */
/* and connect to TELEPORT.COM, a provider in the Portland, OR area. */
/* Teleport has multiple routers you may connect to and they are assigned */
/* based on next unused connection in the telephone switch 'hunt' group. */
/* Each router is a NetBlazer with a different IP address. The routers */
/* assign the remote IP address (user's) from a pool of addresses. This */
/* script handles the prompts and responses unique to Teleport. It is a */
/* starting place for a script that handles dynamic router and remote IP */
/* addresses. Before you modify this, I recommend connecting with your */
/* provider using Hyperaccess or some other terminal program to capture */
/* the connection prompts and responses. Look for things like carraige */
/* returns you may have to strip off. */
/* */
/* 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. This parm passing doesn.t seem to work. If any knows */
/* why, please post. Additionally, this script contains a routine to */
/* take in the password if modified and used standalone with a slip.cfg */
/* file. */
/* */
/* This script was pieced together from several examples. Since it works */
/* I haven't messed with it. */
/* */
/* */
/* TO SETUP: (Teleport config used as an example) */
/* You will need the information from your provider. */
/* */
/* 1. Start Dial Other 'Provider Internet Provider' app. */
/* 2. Select 'Add Provider' */
/* 3. On page 1 enter the following: */
/* Provider Name: teleport */
/* Login ID: XXXXXX (your id) */
/* Password: XXXXXX */
/* Nickname: teleport */
/* Phone Number: 220-2276 */
/* Login Script: teleport.cmd */
/* */
/* 4. On page 2 enter the following: */
/* MTU Size: 1006 */
/* select VJ compression */
/* Domain Nameserver: 192.108.254.11 */
/* Your Domain Name: teleport.com */
/* */
/* 5. Select 'OK' */
/* 6. Copy this scrip to your \tcpip\bin dir */
/* 7. Rock and Roll! */
/* */
/* Teleport connects with the following prompts and responses. This script */
/* identifies the router by parsing the login script and using a REXX */
/* select statement to assign address. The remote IP address is parsed */
/* from the response from the teleport router. This address has a CRLF */
/* that needs to be stripped off. */
/* */
/* TELEPORT PROMPTS: */
/* nb-xxxx login: (where xxxx can be: pdx1, pdx2, pdx3, pdx4, vanc, salem) */
/* Password: */
/* */
/* TELEPORT RESPONSES: */
/* Set IP address of interface 'username-slip' */
/* Packet mode enabled for IP address: xxx.xxx.xxx.xxx */
/* */
/* */
/*--------------------------------------------------------------------------*/
/* CHANGES */
/* 11/22/94 bhh Added correct logic for all nb routers */
/*--------------------------------------------------------------------------*/
parse arg interface , dialcmd username password gateway
/*--------------------------------------------------------------------------*/
/* Initialization and Main Script Code */
/*--------------------------------------------------------------------------*/
/* Set some definitions for easier COM strings */
cr='0d'x
crlf='0d0a'x
blazer=''
router_addr=''
local_addr=''
say ''
say 'Teleport Connection Script '
say ''
/* Since the parm passing mechanism from the program doesn't seem to work */
/* for me, I am hard coding the dial code, username and password. */
dialcmd='atm0dt220-2276'
/* Put user id here. */
username='xxxxxxx'
/* Put user password here. */
password='xxxxxxx'
/* 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 */
/* The following is used with a Supra v32bis modem */
all lineout , 'Reset modem...'
call send 'AT&F2' || 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
/* Wait for connection */
maxtries=20
tries=0
pause=30
busy=1
do while (busy=1)
index=0
call charout , 'Now Dialing... '
call send dialcmd || cr
call waitfor 'CONNECT', 30 ; call flush_receive 'echo'
index=pos('BUSY', waitfor_buffer)
if (index > 0) then
do
tries=tries+1
if (tries>maxtries) then
do
exit 0
end
say ''
call charout , 'retrying '|| tries || ' of ' || maxtries||'... '
end
index=pos('CONNECT', waitfor_buffer)
if (index > 0) then
do
busy=0
end
end
/* 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' */
/* Teleport has multiple routers. Need to check login prompt */
call waitfor 'nb-'
blazer=substr(remain_buffer,1,4)
call flush_receive 'echo'
select
when blazer = 'pdx1' then
router_addr='192.108.254.66'
when blazer = 'pdx2' then
router_addr='192.108.254.67'
when blazer = 'pdx3' then
router_addr='192.108.254.69'
when blazer = 'pdx4'
router_addr='192.108.254.70'
when blazer = 'sale' /* Salem */
router_addr='192.108.254.68'
when blazer = 'vanc'
router_addr='192.108.254.65'
end
call send username || cr
call waitfor 'Password:' ; call flush_receive 'echo'
call send password || cr
/* Teleport Replies with string 'Packet mode enabled for IP address XXX.XXX.XXX.XXX' */
/* Use get_rest to handle selays flush_receive will not. */
/* Need to strip crlf from address so ifconfig and route works. */
call waitfor 'enabled for IP address: ' ; call get_rest
str_addr = remain_buffer
length_addr=length(str_addr)
local_addr=substr(str_addr,1,length_addr-2)
call flush_receive
/* Now configure this host for the appropriate address, */
/* and for a default route through teleport. */
say str_addr
'ifconfig sl0' local_addr router_addr
'route -fh add host' router_addr local_addr '0'
'route add default' router_addr '1'
say '*** SLIP Connection Established ***'
/* 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. (For use as a standalone REXX script) */
/* */
/*--------------------------------------------------------------------------*/
readpass:
answer = ''
do until key = cr
key = slip_getch()
if key \= cr then do
call charout '*'
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 250ms, 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
/*--------------------------------------------------------------------------*/
/* get_rest () */
/*..........................................................................*/
/* */
/* Use get_rest to handle selays flush_receive will not. */
/* */
/*--------------------------------------------------------------------------*/
get_rest:
restline='XXX'
do until restline = ''
restline = slip_com_input(interface,,500)
remain_buffer = remain_buffer||restline
end
return