home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Meeting Pearls 3
/
Meeting_Pearls_III.iso
/
Pearls
/
tcp
/
Networking
/
TCP
/
Dial
/
AmiTCP_dialup
/
SLIPUP.REXX
< prev
Wrap
OS/2 REXX Batch file
|
1993-12-28
|
8KB
|
207 lines
Article 19813 of comp.sys.amiga.datacomm:
Newsgroups: comp.sys.amiga.datacomm
Path: news.Hawaii.Edu!ames!sgiblab!swrinde!cs.utexas.edu!koriel!lll-winken.llnl.gov!taurus.cs.nps.navy.mil!rovero
From: rovero@skye.oc.nps.navy.mil (Josh Rovero)
Subject: Improved SLIP script
Message-ID: <CIBKsM.627@taurus.cs.nps.navy.mil>
Sender: news@taurus.cs.nps.navy.mil
Organization: Naval Postgraduate School,Monterey CA
Date: Mon, 20 Dec 1993 06:02:45 GMT
Lines: 193
Now that the Christmas tree is up and all the shopping done, I've
had a chance to clean up the ARexx script I use for connecting
to a terminal server that assigns dynamic IP addresses.
Be certain to modify all installation specific strings and numbers
before running the script.
It should be pretty easy to modify this so that it checks to see
if AmiTCP is already running, and to use AmiTCP's ARexx port. It'll
have to wait until the kids are back in school, though.
/* SLIPUP.REXX */
/* */
/* Version 1.0, 11 December 1993, by P.J. Rovero */
/* 1.2, 19 December 1993 */
/* */
/* An ARexx script that will dial a terminal server, connect, determine the */
/* dynamically assigned IP address, and start the proper components of */
/* AmiTCP 2.x. The script uses rexxserdev.library v2.0 by Joseph M. */
/* Stivaletta. */
/* */
/* Inspired by Dave Bolen's REXX/2 SLIPUP.CMD for IBM OS/2 TCPIP 1.2.1 */
/* */
/* ------------------------------------------------------------------------- */
/* Start the required libraries */
say 'Opening libraries......'
check = addlib('rexxsupport.library', 0, -30, 0)
if (check == 0) then say 'Rexxsupport library did not open...'
check = addlib('rexxarplib.library', 0, -30, 0)
if (check == 0) then say 'Rexxarplib did not open......'
check = addlib('rexxserdev.library', 0, -30, 0)
if (check == 0) then say 'Rexxserdev did not open......'
/* Define modem strings and other initialization stuff */
say 'Initializing.........'
cr = '0d'x
crlf = '0d0a'x
response = 'OK'
dialcommand = 'ATDT###-####' /* Put your number here */
passwd = 'XXX'||crlf /* Put your passwd here */
tsb_prompt = 'TSB>'||crlf
slipstr = 'Your IP'
slip_cmd = 'slip'||crlf
dest_addr = '###.###.##.##' /* Put your destination IP here */
buffer = allocmem( 512 )
junk = c2d( buffer )
/* Open the serial device and talk to the modem */
/* Mine happens to be a 2400 baud Hayes-compatible on serial unit 2 */
say 'Setting up serial device.....'
serhandle = SerOpen('serial.device', 2)
check = SerClear(serhandle)
check = SerSetParms( serhandle, 2400, 8, N, 1, 0 )
dialstr = dialcommand||crlf
check = SerWrite( serhandle, dialstr, length( dialstr))
/* Wait for a connection and the modem status string */
say 'Dialing the terminal server..... '
check = 0
totalstr = ''
do forever
status = SerQuery( serhandle )
parse upper var status valid bytes_read status_bits .
rcvdstr = SerRead( serhandle, junk, bytes_read )
totalstr = totalstr||rcvdstr
check = modem_query(totalstr)
if (check == 100) then leave
result = delay(100)
end
totalstr = ''
say 'Modem has connected to the terminal server....'
result = startslip()
exit result
/* ------------------------------------------------------------- */
/* ------------------------------------------------------------- */
/* procedure startslip */
/* ------------------------------------------------------------- */
/* Start and configure AmiTCP for SLIP */
startslip:
/* send CRLF to terminal server */
say 'Sent CRLF to server....'
check = SerWrite( serhandle, crlf, length( crlf ))
/* Wait for 'Password:' prompt */
call wait_str('Password:')
say 'Received password prompt....'
/* Send password, wait for TSB> prompt, issue SLIP command */
check = SerWrite( serhandle, passwd, length( passwd ))
say 'Sent password, now waiting for terminal server prompt....'
call wait_str(tsb_prompt)
say 'Terminal server prompt received, now sending slip command....'
check = SerWrite( serhandle, slip_cmd, length( slip_cmd))
check = SerRead( serhandle, junk, length(slip_cmd))
call wait_str(slipstr)
say 'SLIP address received from terminal server.......'
/* Ok, now we have all the data we need to start slip */
/* Close down the serial port but leave the line up (ignore DTR) */
check = SerClose( serhandle )
parse var rcvdstr . 'Your IP address is' a '.' b '.' c '.' d .
d = strip(d,'T',',')
ip_addr = a||'.'||b||'.'||c||'.'||d
say 'The address for this session is ' ip_addr
say 'Starting AmiTCP....'
/* Start AmiTCP */
address command
'run AmiTCP:AmiTCP'
'sys:rexxc/WaitForPort AMITCP'
'wait 2 secs'
/* Set myhost and env:sana2/slip0.config up to reflect ip_addr */
/* *** Be sure to set this for *your* machine and domain *** */
'setenv myhost "' ip_addr ' slb'||d||'.cc.nps.navy.mil amiga"'
check = open(temp,'env:sana2/slip0.config','W')
temp_str = 'serial.device 2 2400 '||ip_addr
check = writeln(temp,temp_str)
check = close(temp)
/* Continue AmiTCP configure and startup */
/* Configure loopback device */
'AmiTCP:bin/ifconfig lo/0 127.1'
/* Configure SLIP */
'AmiTCP:bin/ifconfig devs:networks/rhslip.device/0 '||ip_addr||' '||dest_addr||' netmask 255.255.255.0'
/* Add route to this host */
'AmiTCP:bin/route add slb'||d||'.cc.nps.navy.mil localhost'
/* Add default gateway; replace with *your* router */
'AmiTCP:bin/route add default ###.###.##.#'
/* Start the internet super server */
'run AmiTCP:bin/inetd'
'mount TCP: from devs:Inet-Mountlist'
check = freemem(buffer,512)
say 'AmiTCP started.....'
return 0
/* ------------------------------------------------------------- */
/* ------------------------------------------------------------- */
/* Subroutine wait_str returns when argument string is received */
/* ------------------------------------------------------------- */
wait_str:
teststr = arg(1)
check = 0
do until (check ~= 0)
status = SerQuery( serhandle )
parse upper var status valid bytes_read status_bits .
rcvdstr = SerRead( serhandle, junk, bytes_read )
check = pos(teststr,rcvdstr)
test = delay(50)
end
return
/* ------------------------------------------------------------- */
/* ------------------------------------------------------------- */
/* Subroutine modem_query determine modem status */
/* ------------------------------------------------------------- */
modem_query: procedure
teststr = arg(1)
connectstr = 'CONNECT'
busystr = 'BUSY'
nocarrierstr = 'NO CARRIER'
test = pos(connectstr, teststr)
if (test ~= 0) then return 100
test = pos(busystr, teststr)
if (test ~= 0) then exit(10)
test = pos(nocarrierstr, teststr)
if (test ~= 0) then exit(10)
return 0
/* ------------------------------------------------------------- */
--
Josh Rovero (rovero@oc.nps.navy.mil) | Packet: KK1D @ K6LY
Department of Oceanography, Code OC/Rv |
Naval Postgraduate School |
Monterey, CA 93943 (408) 656-2084 |