APPENDIX 1 - SLIP/PPP Dialup & Login Scripts

Trumpet login.cmd

The following is the recommended login.cmd script for UQ dialin. It always prompts you for phone number, username and password. In general, avoid using scripts that save your password. Such scripts store your password in trumpwsk.ini, and even though this may not always be a security hazard, it does create problems whenever you are required to change your password (you will be forced to make changes to login.cmd as well as trumpwsk.ini).
# Last edited : 21/10/96 (MM - new UQ modem bank numbers)
#
# set up some strings for dialling up
#
if ![load $modeminit]
   $modeminit="&f\n5%c1"
   save $modeminit
end
$prompt = "nnex:"
$userprompt = "sername:"
$passprompt = "assword:"
$slipcmd = "slip"
$addrtarg = "ur address is"
$pppcmd = "ppp"

%attempts = 10
#
#
#----------------------------------------------------------
#
# initialize modem
#
output "atz" \13
if ! [input 10 OK\n]
  display "Modem is not responding"\n
  abort
end
#
# setup our modem commands
#
output "at"$modeminit \13
input 10 OK\n
#
# send phone number
#
%pn = 0
%n = 0
repeat
  if %n = %attempts
    display "Too many dial attempts"\n
    abort
  end
  sleep 2
#
# Select a telephone number
display "PAYING CLIENTS ONLY banks ."\n
display "A. 3291 2577 : 300 - 28.8k(V.34 and V.fast)"\n
display "B. 3870 7257 : 300 - 28.8k(V.34)"\n
display \n
display "STUDENTS and STAFF ONLY banks."\n
display "C. 33354099  : 300 - 28.8k(V.34 and V.fast)"\n
display "D. 38703227  : 300 - 28.8k(V.34) General use."\n
display \n
display "STAFF ONLY bank ."\n
display "E. 33354079  : 300 - 28.8k(V.34 and V.Fast)"\n
display \n
display "FAST TURN AROUND bank. (general access)"\n
display "F. 33354089   : 300 - 28.8k(V.34 and V.fast)"\n 
display \n
display "G. User specified"\n
query $pn "Select A, B, C, D, E, F or G."
if ($pn="A") | ($pn="a")
  output atdt32912577\13
  %pn = 1
end
if ($pn="B") | ($pn="b")
  output atdt38707257\13
  %pn = 1
end
if ($pn="C") | ($pn="c")
  output atdt33354099\13
  %pn = 1
end
if ($pn="D") | ($pn="d")
  output atdt38703227\13
  %pn = 1
end
if ($pn="E") | ($pn="e")
  output atdt33354079\13
  %pn = 1
end
if ($pn="F") | ($pn="f")
  output atdt33354089\13
  %pn = 1
end
if ($pn="G") | ($pn="g")
  query $number "Enter phone number"
  output atdt$number\13
  %pn = 1
end
if !%pn
  abort
end
#
# now we should be connected.
#
  %ok = [input 60 CONNECT]
  %n = %n + 1
until %ok
#
#  wait till it's safe to send because some modem's hang up
#  if you transmit during the connection phase
#
wait 30 dcd
#
# now prod the terminal server
#
output \13
#
#  wait for the username prompt
#
input 30 $userprompt
username "Enter your username"
output \u\13
#
# and the password
#
input 30 $passprompt
password "Enter your password"
output \p\13
#
# we are now logged in
#
input 30 $prompt
#
if %ppp
  #
  # jump into ppp mode
  #
  output $pppcmd\13
  #
  input 30\n
  #
  display "PPP mode selected.  Will try to negotiate IP address."\n
  #
else
  #
  # jump into slip mode
  #
  output $slipcmd\13
  #
  # wait for the address string
  #
  input 30 $addrtarg
  #
  # parse address
  #
  address 30
  input 30\n
  #
  # we are now connected, logged in and in slip mode.
  #
  display \n
  display "Connected - your address is "\i\n
end
#
# now we are finished.
#

Windows 95 Dial-up Networking - Microsoft Scripting Tool

Thanks to Xiang Du for the following script written with the "Dial-up scripting tool" in MS-Plus Pack.
;
; This is a script file that demonstrates how
; to establish a ppp connection with a host.
;
; A script file must have a 'main' procedure.
; All script execution starts with this 'main'
; procedure.
;


; Main entry point to script
;
proc main

   ; Change these variables to customize for your
   ; specific Internet service provider.

   integer nTries = 3

   ; This is the login prompt and timeout values

   string szLogin = "username:"
   integer nLoginTimeout = 3

   ; This is the password prompt and timeout values

   string szPW = "password:"
   integer nPWTimeout = 3

   ; This is the prompt once your password is verified

   string szPrompt = "annex:"

   ; This is the command to send to establish the 
   ; connection.  This script assumes you only need
   ; to issue one command to continue.  Feel free
   ; to add more commands if your provider requires
   ; it.

   string szConnect = "ppp^M"

   ; Set this to FALSE if you don't want to get an IP
   ; address

   boolean bUseSlip = FALSE


   ; Delay for 2 seconds first to make sure the
   ; host doesn't get confused when we send the
   ; two carriage-returns.

   delay 2
   transmit "^M^M"

   ; Attempt to login at most 'nTries' times

   while 0 < nTries do

      ; Wait for the login prompt before entering
      ; the user ID, timeout after x seconds

      waitfor szLogin then DoLogin 
        until nLoginTimeout

TryAgain:
      transmit "^M"        ; ping
      nTries = nTries - 1

   endwhile

   goto BailOut

DoLogin:
   ; Enter user ID

   transmit $USERID, raw
   transmit "^M"

   ; Wait for the password prompt 

   waitfor szPW until nPWTimeout
   if FALSE == $SUCCESS then
      goto TryAgain
   endif

   ; Send the password

   transmit $PASSWORD, raw
   transmit "^M"

   ; Wait for the prompt

   waitfor szPrompt

   transmit szConnect

   if bUseSlip then
      ; An alternative to the following line is
      ;
      ;     waitfor "Your address is "
      ;     set ipaddr getip
      ;
      ; if we don't know the order of the IP addresses.

      set ipaddr getip 2
   endif

   goto Done

BailOut:
   ; Something isn't responding.  Halt the script
   ; and let the user handle it manually.

   set screen keyboard on
   halt

Done:

endproc

Windows 95 Dial-up Networking - RoboDun Script

Note that the script includes codes for carriage return (cr) characters enclosed in angle brackets. To save in the correct format, you will need to select the text, copy it to the clipboard, and then paste into a new document.

    # RoboDun PPP login script for Window 95
    # Send CR/LF to get the ball rolling
    Send ""

    # Wait 10 seconds for "username" prompt
    WaitFor "sername:", 10

    # Send user name in response to "NetLogin:"
    Send   "username<cr>"

    # Wait 10 second for "Password:" prompt
    WaitFor "assword:", 10

    # Send password in response to prompt
    Send   "password<cr>"

    # Wait for "Annex:" prompt
    WaitFor "nnex:", 10

    # Specify service...PPP in this case
    Send "ppp<cr>"
    Done

InterSLIP Gateway Script for UQ Annexes

    ! Basic Annex Gateway Script version 1.0a
    ! Rick Ernst
    !
    ! InterSLIP gateway script for Annex terminal server which has 
    ! been configured to give users a command line interface to the 
    ! terminal server.
    !
    !
    settries 0
    note "Giving the annex a second.."
    pause 30
    !
    ! Most Annex terminal servers give a "Annex username:" prompt.  
    ! Some do a "MachineName username:" so we look for "username".
    !
    @login
    note "Sending carriage returns waiting to be prompted for username..."
    write "\13\13\13"
    matchstr 1 username "username:"
    matchread 60
    note "Trying again ..."
    inctries
    iftries 5 unsuccessful
    jump login
    !
    @username
    note "Sending username ... ^5"
    write "^5\13"
    matchclr
    matchstr 1 password "password:"
    matchread 120
    note "Gateway not responding!"
    jump unsuccessful
    !
    @password
    note "Sending password"
    write "^6\13"
    matchclr
    matchstr 1 denied "Username/Password Incorrect"
    matchstr 2 successful "Permission granted"
    matchread 240
    jump unsuccessful
    !
    @denied
    note "Access Denied, Bad password?"
    jump unsuccessful
    !
    @successful
    note "Waiting for annex prompt..."
    matchclr
    matchstr 1 slip "annex"
    matchread 240
    jump unsuccessful
    !
    @slip
    note "Sending slip command"
    write "slip\13"
    matchclr
    matchstr 1 address "Your address"
    matchread 240
    jump unsuccessful
    !
    @address
    note "Waiting for your address..."
    matchclr
    matchexp 1 connected "[0-9]*\\.[0-9]*\\.[0-9]*\\.[0-9]*"
    matchread 60
    jump unsuccessful
    !
    @connected
    note "Your address is: ^0"
    setip "^0"
    setmtu "^9"
    pause 60
    exit 0
    !
    ! currently unused:
    !
    @answer
    @hangup
    exit 0
    !
    !
    @unsuccessful
    note "SLIP Connection was unsuccessful"
    sound Indigo
    pause 60
    exit -1

Linux PPP Script

Thanks to Robert Brockway for the following Linux script and installation utilities. Robert writes :-

Below is a shar file which will install the file ppp.nopasswd. Mv this to ppp, then follow the installation instructions inside the file. If you have any problems with this, feel free to email me at robert@zen.humbug.org.au.

#!/bin/sh
# This is a shell archive (produced by GNU sharutils 4.2).
# To extract the files from this archive, save it to some FILE, remove
# everything before the `!/bin/sh' line above, then type `sh FILE'.
#
# Made on 1997-09-15 12:36 EST by .
# Source directory was `/home/robert'.
#
# Existing files will *not* be overwritten unless `-c' is specified.
#
# This shar contains:
# length mode       name
# ------ ---------- ------------------------------------------
#   5014 -rwx------ ppp.nopasswd
#
save_IFS="${IFS}"
IFS="${IFS}:"
gettext_dir=FAILED
locale_dir=FAILED
first_param="$1"
for dir in $PATH
do
  if test "$gettext_dir" = FAILED && test -f $dir/gettext \
     && ($dir/gettext --version >/dev/null 2>&1)
  then
    set `$dir/gettext --version 2>&1`
    if test "$3" = GNU
    then
      gettext_dir=$dir
    fi
  fi
  if test "$locale_dir" = FAILED && test -f $dir/shar \
     && ($dir/shar --print-text-domain-dir >/dev/null 2>&1)
  then
    locale_dir=`$dir/shar --print-text-domain-dir`
  fi
done
IFS="$save_IFS"
if test "$locale_dir" = FAILED || test "$gettext_dir" = FAILED
then
  echo=echo
else
  TEXTDOMAINDIR=$locale_dir
  export TEXTDOMAINDIR
  TEXTDOMAIN=sharutils
  export TEXTDOMAIN
  echo="$gettext_dir/gettext -s"
fi
touch -am 1231235999 $$.touch >/dev/null 2>&1
if test ! -f 1231235999 && test -f $$.touch; then
  shar_touch=touch
else
  shar_touch=:
  echo
  $echo 'WARNING: not restoring timestamps.  Consider getting and'
  $echo "installing GNU \`touch', distributed in GNU File Utilities..."
  echo
fi
rm -f 1231235999 $$.touch
#
if mkdir _sh00931; then
  $echo 'x -' 'creating lock directory'
else
  $echo 'failed to create lock directory'
  exit 1
fi
# ============= ppp.nopasswd ==============
if test -f 'ppp.nopasswd' && test "$first_param" != -c; then
  $echo 'x -' SKIPPING 'ppp.nopasswd' '(file already exists)'
else
  $echo 'x -' extracting 'ppp.nopasswd' '(text)'
  sed 's/^X//' << 'SHAR_EOF' > 'ppp.nopasswd' &&
#!/bin/bash
X
#
# Version 3.0
#
X
#
# Set up a PPP link to The University of Queensland from a Linux box.
# Should also work on FreeBSD and NetBSD with a few minor changes.
# Originally based on the default ppp-on script, this script has been heavily
# modified in the last 2 years.
# Permission is granted for unlimited distribution of original or modified
# versions of this script in electronic or other format as long as this
# comment block is retained intact.
# Copyright Robert Brockway 1995.
# Last modified: 15th September 1997.
#				--Robert Brockway.
#
X
# Best to leave this alone :-)
VERSION=3.0
X
#
# Installation
#
# Call this file something easy to remember, say ppp, then 'chown root'
# and 'chmod go-rwx' the file, as it contains passwords.  Then go through
# and modify the various configuration options below.
# If you experience problems, or have suggestions as to how to make this
# script better, feel free to email me at robert@zen.humbug.org.au.
#
X
#
# Configuration
#
# Fill in these variables to be appropriate for your local setup.
#
X
# Student account.  Leave blank if you do not have a student account.
STUDENT_USER=
STUDENT_PASSWORD=
STUDENT_PHONELIST="33354099 38640198" 
X
# Staff account.  Leave blank if you do not have a staff account.
STAFF_USER=
STAFF_PASSWORD=
STAFF_PHONELIST="33354079 33354099 38640178"
X
# Commercial or other account.  Leave blank if you do not have a commercial or other account.
OTHER_USER=
OTHER_PASSWORD=
OTHER_PHONELIST="38341569 33354067 33354069 32912568 38707257 32912577"
X
# Put in fast turnaround modem bank numbers here.
FASTBANK=33354089
X
# Put in Questnet modem bank numbers here, as they have a different
# annex prompt.
QUESTNET=38640198
X
# Make sure the paths to these files are valid and correct.
LOGFILE=~/log/ppplog
DOWNFILE=/etc/ppp.down
X
# Make sure this is a full path to the device file.
# If you use /dev/modem, make sure the link points at the right device file.
DEVICE=/dev/cua3
X
# Put your modem init string here.
HAYES=M0
X
# Enter the speed of the serial port (bps).
SPEED=57600
X
# See pppd(8) for details of these switches.
PPPCONF="defaultroute mtu 296 mru 296 asyncmap 0 ipcp-accept-local ipcp-accept-remote bsdcomp 15,15 crtscts modem"
X
#
# The real work
#
X
# Determine what function we actually want to invoke.
case $1 in
-u)
X	case $2 in
X	student)
X		USER=$STUDENT_USER
X		PASSWORD=$STUDENT_PASSWORD
X		PHONELIST=$STUDENT_PHONELIST
X		;;
X	staff)
X		USER=$STAFF_USER
X		PASSWORD=$STAFF_PASSWORD
X		PHONELIST=$STAFF_PHONELIST
X		;;
X	other)
X		USER=$OTHER_USER
X		PASSWORD=$OTHER_PASSWORD
X		PHONELIST=$OTHER_PHONELIST
X		;;
X	*)
X		echo "Please enter type of dialup account: student, staff or other after ppp -u"
X		exit
X		;;
X	esac
X	case $3 in
X	-f)
X		PHONELIST=$FASTBANK
X		;;
X	esac
X	for PHONE in $PHONELIST
X	do
X		(
X		stty $SPEED -tostop
X		# Setup for Questnet modem bank support
X		#if $PHONE==$QUESTNET
X		#then
X		#	LOGIN="name: $USER word: $PASSWORD nnex: ppp"
X		#else
X		#	LOGIN="name: $USER word: $PASSWORD nnex: ppp"
X		#fi
X		LOGIN="name: $USER word: $PASSWORD nnex: ppp"
X		if /usr/sbin/chat -v ABORT 'NO CARRIER' ABORT BUSY '' ATZ OK AT$HAYES OK ATDT$PHONE CONNECT \r\r\r\r\r\r $LOGIN
X		then
X			/bin/date >> $LOGFILE
X			/usr/sbin/pppd $DEVICE $PPPCONF
X			sleep 10
X			exit 0
X		else
X			exit 1
X		fi
X		) < $DEVICE > $DEVICE
X	done
X	;;
-d)
X	# mail buffer flushed to prevent messages being caught in the queue
X	# before the link goes down.  This is fine for sendmail or smail,
X	# modify for qmail.
X	sendmail -q
X
X	# shutdown ppp link
X	wall $DOWNFILE
X	sleep 60
X	killall pppd
X	killall ppp
X	;;
-l)
X	echo -n "Modem usage statistics for host "
X	hostname
X	echo
X	echo -n "Earliest record: "
X	head -n 1 ~/log/ppplog
X	echo
X	echo -n "Latest record: "
X	tail -n 1 ~/log/ppplog
X	echo
X	echo -n "Total connects: "
X	cat ~/log/ppplog | wc -l
X	echo
X	echo "Month"
X	echo "-----"
X	for MONTH in Jan Feb Mar Apr May Jun Jul Aug Sep Oct Nov Dec
X	do
X        	echo -n $MONTH ":"
X        	cat ~/log/ppplog | grep $MONTH | wc -l
X	done
X	echo 
X	echo "Day"
X	echo "---"
X	for DAY in Mon Tue Wed Thu Fri Sat Sun
X	do
X        	echo -n $DAY ":"
X        	cat $LOGFILE | grep $DAY | wc -l
X	done
X	;;
-v)
X	echo -n "ppp version" $VERSION
X	echo
X	;;
*)
X	echo "Initiate a ppp link with The University of Queensland."
X	echo
X	echo "Usage:		ppp [-u student|staff|other] [-dlv] [-f]"
X	echo
X	echo "Options:	-u	Dials out and negotiates the ppp link."
X	echo "			This option must be followed by one of"
X	echo "			student, staff or other corresponding to"
X	echo "			the type of account being used."
X	echo "			Optionally followed by -f for access to"
X	echo "			a 'fast turn around' modem bank."
X	echo
X	echo "		-d	Issues the contents of $DOWNFILE to all"
X	echo "			users in utmp, sleeps for 60 seconds then"
X	echo "			shuts down the ppp link."
X	echo
X	echo "		-l	Lists various statistics gathered from the"
X	echo "			logs kept in $LOGFILE."
X	echo
X	echo "		-v	Prints version information."
X	echo
X	echo "		Executing ppp without a valid switch will result in"
X	echo "		this help page being displayed."
X	;;
esac
SHAR_EOF
  $shar_touch -am 0915123497 'ppp.nopasswd' &&
  chmod 0700 'ppp.nopasswd' ||
  $echo 'restore of' 'ppp.nopasswd' 'failed'
  if ( md5sum --help 2>&1 | grep 'sage: md5sum \[' ) >/dev/null 2>&1 \
  && ( md5sum --version 2>&1 | grep -v 'textutils 1.12' ) >/dev/null; then
    md5sum -c << SHAR_EOF >/dev/null 2>&1 \
    || $echo 'ppp.nopasswd:' 'MD5 check failed'
2da28c4e94d4f979bb383ac796a9c8ec  ppp.nopasswd
SHAR_EOF
  else
    shar_count="`LC_ALL= LC_CTYPE= LANG= wc -c < 'ppp.nopasswd'`"
    test 5014 -eq "$shar_count" ||
    $echo 'ppp.nopasswd:' 'original size' '5014,' 'current size' "$shar_count!"
  fi
fi
rm -fr _sh00931
exit 0