TCLUG Archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [TCLUG:2395] connecting to the U
Hello all:
Here's the dialer script I use. I munged the passwords and
the usernames, but all else is pristine.
Note that this script logs modem connect times/speeds to
/var/log/modem. Neat!
John
------------------------------------------------------
#!/bin/sh
#
# /etc/ppp/scripts/dialer-script-umn
#
# This script automates the interaction portion of connecting
# with the University of Minnesota modem pool.
#
# Note that this is a (relatively) secure script; any password
# used in the 'chat' portion of the script is placed in a file
# and so will not be visible to a user with the 'ps' command.
#
#---------------------------------------------------------------------
# remove any old "dialer-chat.*.*.txt" files
#---------------------------------------------------------------------
/bin/rm -f /etc/ppp/scripts/dialer-chat.*.*.txt
#---------------------------------------------------------------------
# Choose account parameters based on the day of the year
#
# NOTE: dial prefix '*70,' disables call-waiting
#---------------------------------------------------------------------
DAYOFYEAR=`/bin/date "+%j"`
ODDEVEN=`/usr/bin/expr $DAYOFYEAR % 2`
if [ "$ODDEVEN" = "0" ]; then
ACCOUNT=trammell@foo.com
PASSWORD=gates
TELEPHONE=*70,852-5252
else
ACCOUNT=trammell@bar.com
PASSWORD=sucks
TELEPHONE=*70,852-5252
fi
#----------------------------------------------------------------
# generate the chat script file name
#----------------------------------------------------------------
TIMESTAMP=`/bin/date "+%s"`
TIMESTAMP=`/usr/bin/expr $TIMESTAMP % 10000`
RANDSTAMP=`/usr/bin/expr $RANDOM % 10000`
FILENAME="/etc/ppp/scripts/dialer-chat.${TIMESTAMP}.${RANDSTAMP}.txt"
#----------------------------------------------------------------
# generate an empty chat script file with correct permissions
#----------------------------------------------------------------
/bin/touch ${FILENAME}
/bin/chmod 640 ${FILENAME}
/bin/chown root.ppp ${FILENAME}
#----------------------------------------------------------------
# generate the chat script
#----------------------------------------------------------------
cat >> ${FILENAME} <<EndOfChatScript
ABORT '\nBUSY\r'
ABORT '\nNO ANSWER\r'
ABORT '\nNO DIALTONE\r'
ABORT '\nRINGING\r'
REPORT CONNECT
TIMEOUT 2
'' '\rAT'
'OK-+++\c-OK' 'ATH0'
TIMEOUT 30
OK "ATDT $TELEPHONE"
CONNECT ''
'University policy' ''
'Username:' "$ACCOUNT"
'word:--word:' "$PASSWORD"
'server' 'ppp default\r\r'
EndOfChatScript
#----------------------------------------------------------------
# invoke the chat script
#----------------------------------------------------------------
exec /usr/sbin/chat -r /var/log/modem -f ${FILENAME}