From:
[email protected] (Frank E. Smith)
Subject: MacSLIP scripts
Here are two MacSLIP scripts that I modified from the sample.script that
comes with MacSLIP. I have used the Netcom script (mac-slip-netcom..) for
some time now without any problems. And it is setup to start The Internet
Adapter (TIA) on a Netcom shell account. The UUNet script
(mac-slip-uunet..) is one I just modified to work on my UUNet PPP account.
So far it seems to work OK.
I hope these scripts help others get up on their accounts in less time than
it took me.
Frank E. Smith (
[email protected] soon to be
[email protected])
#
# Sample.script
#
# This is a generic script for logging into a SLIP/PPP server
# You may need to modify it to work with your SLIP/PPP server or
# use one of the more specific scripts.
#
# This script is designed to dial a Hayes compatible modem.
#
# The first time this script runs, it will prompt for your username,
# password, and phone number to dial. These settings will be saved
# for subequent connections.
#
# Using default settings, the modem will be initialized before this script
# starts running. Make sure the "Init modem when connecting" option
# is set in the "Modem" menu and that you have made an appropriate
# modem selection.
#
# To call a list of phone numbers when getting busy signals, define
# the numbers in $ph_num_1, $ph_num_2, ..., instead of $phone
#
ignore var busygo p_index
# If user is not defined, ask for it.
ifdef user goto skipuser
message ""
message "\bEnter your login username."
ask var
define user "$var"
label skipuser
# if password is not defined, ask for it
ifdef password goto skippass
message "Will login as $user.\n\bPassword:"
askp var
define /h password "$var"
label skippass
# if phone is not defined, ask for it. Preset phone from
# ph_num_1 if it is defined.
do next_phone_number
ifdef phone else
message "\bEnter the phone number to dial"
ask var
define phone "$var"
endif
# Let the user know we're starting up
label startup
message "Script starting..."
# Setup action handlers
on restart goto restart
on abort goto abort
# Dial the phone and wait for the terminal server to send its login
# banner. Some areas support using *70 as a dialing prefix to suppress
# call-waiting tones which will probably cause your modem
# to lose the connection. Some terminal servers may require you to
# autobaud before they will respond. Allow enough time for the modem
# handshake to complete.
label dial
ifdef INITMODEM goto skipwarn
beep
message "\bYou should select a modem using Configure"
label skipwarn
message "Dialing $phone..."
flush
on abort goto hangupabort
send "ATDT $phone\r"
{
ifmatch "name:" break
ifmatch "ogin:" break
ifmatch "NO DIALTONE" goto nodialtone
ifmatch "NO DIAL TONE" goto nodialtone
ifmatch "BUSY" goto phonebusy
ifmatch "NO CARRIER" goto nocarrier
iftime 1:15 goto dialtimeout
}
# Log into the server. Try three times to send the username. Use
# counter #1 to count the number of login attempts.
setcount 1 0
label login
ifcountgt 1 3 goto cantlogin
message "Logging in as $user..."
setcount 0 0
label user
flush
ifcountgt 0 3 goto baduser
send "$user\r"
{
ifmatch "ssword:" break
ifmatch "name:" goto user
ifmatch "ogin:" goto user
iftime 10 goto baduser
}
# Send the password and wait for the prompt. If we see the
# username prompt again, then we didn't get logged in so try again.
message "Sending password..."
flush
send "$password\r"
{
ifmatch "1524." break
ifmatch "1524.\r\n" break
ifmatch "Access denied" goto accessdenied
ifmatch "incorrect" goto accessdenied
iftime 10 goto cantlogin
}
# If the login attempt fails, we land here.
#label accessdenied
#{
# ifmatch "name:" goto login
# ifmatch "ogin:" goto login
# ifmatch "NO CARRIER" goto cantlogin
# iftime 10 goto cantlogin
#}
# Uncomment one of the following "ipfind" lines if your server doesn't
# support BOOTP, but outputs your IP address in its response to
# the slip command. To uncomment the line, delete the leading
# hashmark and space: "# "
#
# Uncomment the following line if your server only outputs the
# your IP address. ex: "Slip connection to 10.2.3.4 beginning".
ipfind IPADDRESS
#
# Uncomment the following line if your server outputs both,
# ex: "Slip session from 10.2.3.1 to 10.2.3.4 beginning"
# ipfind IPGWADDRESS IPADDRESS
#
# Uncomment this line if your server doesn't display the
# gateway address as in the first ipfind command, or if
# your gateway address and your IP address aren't on the same subnet.
# set IPGWADDRESS $IPADDRESS
# All done. Send message to alert the user, flush the junk out of the
# receive buffer, and return success.
message "Script complete"
flush
return 1
# Error handlers.
label abort
beep
message "\bCommand-. seen or Cancel button clicked."
goto aborted
label hangupabort
beep
message "\bCommand-. seen or Cancel button clicked."
goto hangup
label cantfindmodem
beep
message "\bThe modem didn't respond to attention"
message "\bbsignal. Check modem and cabling."
goto aborted
label cantinitmodem
beep
message "\bThe modem didn't respond to initialization"
message "\bstring. Check the modem."
goto aborted
label nodialtone
beep
message "\bThe modem could not detect a dialtone."
message "\bCheck the phone line."
goto aborted
label phonebusy
flush
message "\bThe number $phone is busy."
do next_phone_number
# Uncomment the next line if you always want to redial when busy
# goto redial
if $busygo eq "go" goto redial
on restart goto busygo
beep
message "\bClick "Restart" to keep trying, "OK" to quit."
ask junk
return 0
label busygo
on restart goto restart
set busygo "go"
flush
label redial
do syncmodem
goto dial
label nocarrier
beep
message "\bThe modem could not establish a connection."
message "\bMake sure there is a modem on the other end."
goto aborted
label dialtimeout
message "\bThe modem or server isn't responding."
message "\bTry dialing manually to make sure the modem"
message "\band server are OK."
goto aborted
label baduser
beep
message "\bThe server won't accept a username."
message "\bTry dialing manually to make sure the"
message "\bserver is OK."
goto hangup
label cantlogin
beep
message "\bLogin to server failed, check username"
message "\band password."
goto hangup
label cantsetterm
beep
message "\bCan't set terminal line for $TRANSPORT operation."
goto hangup
label cantstartslip
beep
message "\bCan't put server into $TRANSPORT mode."
goto hangup
# General back-end for bailing out.
label hangup
do disconnect
# fallthrough into aborted
label aborted
message "\bScript aborted!"
message "\bClick "OK" to quit, "Restart" to retry."
# This activates the OK button.
ask junk
flush
return 0
# Restart procedure.
# This label is entered when you click the restart button in the
# connection dialog. We try to force the modem to hang up, then we go back
# to the start of the script.
label restart
do disconnect
message "\bScript restarted."
goto startup
# Disconnect procedure. The "disconect" procedure is called by MacSLIP
# when the "Disconnect" button is clicked. This procedure escapes the
# modem into command mode and hangs up the phone. The +++ escape sequence
# is surrounded by delays that some modems require.
label disconnect
send "\d\d+++\d\dATH\r\d\d"
do syncmodem
return 1
# Alternate disconnect procedure for modems that drop into command mode
# when DTR is dropped. You may want to try this alternate disconnect
# procedure if the one above doesn't work for your modem. Just swap the
# labels to use this one instead of the one above.
label disconnect2
dtr off
delay 3
send "ATH\r"
dtr on
flush
return 1
# Attempt to sync up with the modem, but don't wait forever.
label syncmodem
setcount 4 0
flush
label waitmodem2
ifcountgt 4 2 return
send "AT\r"
{
ifmatch "OK" break
iftime 2 goto waitmodem2
}
flush
return
# This routine sets the phone variable to the next number in
# a list defined as ph_num_1, ph_num_2, ...
# If the ph_num_? variables are not defined, phone is
# unmodified.
label next_phone_number
ifdef ph_num_$p_index then
copyvar ph_num_$p_index phone
incvar p_index
else
# return if no list of phone numbers
if $p_index eq 1 return
set p_index 1
goto next_phone_number
endif
return
# for Emacs
# Local Variables:
# tab-width: 4
# End: