Andre Paris wrote:
> Hi,
> I'm setting up a LAN for a local First Nations(Indian) Band here in
> Burns Lake, British Columbia. A small LAN 1 server(linux) and 4
> workstations(win98), all the training and setting up I will be doing as
> a volunteer. I plan to use diald to call the local ISP, but the local
> ISP instead of having 1 telephone number has several, I'm looking for a
> script that will work in tandem with diald to dial one number and if
> it's busy dial the next until it connects. But my scripting abilities
> have always been lacking, I was hoping someone has already run across a
> similar problem and may have perhaps written a script already to perform
> this action? If you have and you can donate the script to this project
> I and the First Nations Band(the Burns Lake Band) would be greatly
> appreciative, and if need be I will pay you. Thank you in advance.
>
Hi, I have written a script for connecting multiple ISPs with multiple phone
numbers. I think this is more than you need.
Hope you can edit modem initialization if needed. If you use pppd, which
doesn't know +ua parameter, then you must save you ISP username and password
in /etc/ppp/secrets.
---------
Reijo Korhonen
#!/bin/sh
#
# Connect multi ISPs with multi numbers
#
# Reijo Korhonen 25.11.1998
#
# mailto: [EMAIL PROTECTED]
#
#
# Editing hints for you purpose
# This version is written for older pppd, which uses +ua parameter.
# (The newest pppd does know know +ua parametrs, but searches
# username and secred from /etc/ppp/pap-secrets -file.)
# Change ISP names and phonenumbers.
# Functions init_line is modem dependend
# - original version inits max 33600 modem
# - consult you modem manual for changes
#
REPORTFILE=/tmp/ppp_connect.rpt
IO=/tmp/ppp_connect.io
PID_FILE=/var/run/ppp_connect.pid
export REPORTFILE IO PID_FILE
echo $$ > $PID_FILE
rm -f $REPORTFILE
function init_line()
{
/usr/sbin/chat -v REPORT CONNECT REPORT BUSY REPORT 'NO CARRIER' ABORT BUSY
ABORT 'NO CARRIER' TIMEOUT 15 '' 'AT&FX3E0V1\\N3&C1&D2W1S0=0S37=0+MS=11,1,19200,33600'
OK '' 2>> $REPORTFILE
}
function hangup()
{
/usr/sbin/chat -v REPORT CONNECT REPORT BUSY REPORT 'NO CARRIER' ABORT BUSY
ABORT 'NO CARRIER' TIMEOUT 15 '' '+++' '' ATH0 OK '' 2>> $REPORTFILE
}
function connect()
{
for NUMBER in $NUMBERS
do
export NUMBER
/usr/sbin/chat -v REPORT CONNECT REPORT BUSY REPORT 'NO CARRIER' ABORT BUSY ABORT
'NO CARRIER' '' ATDT$NUMBER TIMEOUT 45 CONNECT '' 2>> $REPORTFILE
RET=$?
if [ $RET = 0 ] ; then
echo $NUMBER " Connected OK" >> $REPORTFILE
/usr/sbin/pppd file $OPTIONS crtscts +ua $UA defaultroute &
exit 0
else
echo $NUMBER " Connection failed" >> $REPORTFILE
echo $RET >$IO
fi
done
}
# init modem line
init_line
# try first isp
UA=/etc/ppp/first_isp.ua
export UA
NUMBERS="4455113 4455112 4455111"
export NUMBERS
OPTIONS=/etc/ppp/options.first_isp
export OPTIONS
echo "Connecting to First ISP..." >> $REPORTFILE
connect
# If succeeded, then don't try another ISP
read $result <$IO
if [ $result ] ; then
rm -f $IO
exit 0
fi
# try second isp
UA=/etc/ppp/second_isp.ua
export UA
NUMBERS="9955113 9955112 9955111"
export NUMBERS
OPTIONS=/etc/ppp/options.second_isp
export OPTIONS
echo "Connecting to Secend ISP..." >> $REPORTFILE
connect
# If succeeded, then don't try another ISP
read $result <$IO
if [ $result ] ; then
rm -f $IO
exit 0
fi
# You can add here third isp and so on
# If not succeeded, ruturn result
read $result <$IO
rm -f $IO
exit $result