Sorry about the delay. Every now and then they (the ones that write my 
paychecks) require I do some work for them. Oh, Well!!

Here is the connect script I use to select a different ISP based on it's IP 
address. It's reading the IP address out of the pipe and using it to make a 
decision on which phone number to dial. It could probably stand some 
improvement, but has worked for quite a while so I haven't changed it. I use 
named, but having the name resolution in /etc/hosts would serve just as well. 
You'll need to have at least one entry for each ISP in your box (so it won't 
look outside for the name resolution), otherwise it'll call whatever your first
name server listed in resolv.conf is. To avoid the lost packet I usually start 
a ping to the ISP I want and then bring up Netscape.

Copying of the options and pap-secrets based on the IP is because my 2 
connections needed different parameters to connect.

Using diald 0.99.x. It worked with 0.16.5 also.

#!/bin/sh
# connect script
# set up pipe
cat /etc/diald/monitor.ctl > /etc/diald/monitor &
/bin/sleep 1
echo "monitor /etc/diald/monitor.ctl" > /etc/diald/diald.ctl
/bin/sleep 2
# grep pipe for IP address (I use only the network part)
COUNT=`/usr/bin/grep "xx.xx.xx" /etc/diald/monitor | wc -l`
echo $COUNT > /etc/diald/count
kill `ps x | grep "cat /etc/diald" | cut -c,1-5`

# Configuration parameters
if [ $COUNT = "0" ]
 then
  PHONE_NUMBER="xxxxxxx"
  cp /etc/ppp/pap-secrets-bell /etc/ppp/pap-secrets
  cp /etc/ppp/options-bell /etc/ppp/options 
  USER_NAME="xxxxxxxx"
  PASSWORD="xxxxxxx"
 else
  PHONE_NUMBER="xxxxxxxx"
  cp /etc/ppp/pap-secrets-sam /etc/ppp/pap-secrets
  cp /etc/ppp/options-sam /etc/ppp/options 
#  USER_NAME="xxxxxxx" N.B. commented out because our campus dialup prefers to
#  PASSWORD="xxxxxxx"       authenticate after ppp comes up.
fi


# Copyright (c) 1996, Eric Schenk.
#
# This script is intended to give an example of a connection script that
# uses the "message" facility of diald to communicate progress through
# the dialing process to a diald monitoring program such as dctrl or diald-top.
# It also reports progress to the system logs. This can be useful if you
# are seeing failed attempts to connect and you want to know when and why
# they are failing.
#
# This script requires the use of chat-1.9 or greater for full
# functionality. It should work with older versions of chat,
# but it will not be able to report the reason for a connection failure.

# Configuration parameters

# The initialization string for your modem
MODEM_INIT="ATZ"

# The phone number to dial

# The chat sequence to recognize that the remote system
# is asking for your user name.
USER_CHAT_SEQ="name:--name:--name:--name:--name:--name:--name:"

# The string to send in response to the request for your user name.

# The chat sequence to recongnize that the remote system
# is asking for your password.
PASSWD_CHAT_SEQ="word:"

# The string to send in response to the request for your password.


# The prompt the remote system will give once you are logged in
# If you do not define this then the script will assume that
# there is no command to be issued to start up the remote protocol.
#PROMPT=""
# The command to issue to start up the remote protocol
#PROTOCOL_START="ppp"

# The string to wait for to see that the protocol on the remote
# end started OK. If this is empty then no check will be performed.
#START_ACK="Switching to PPP."

# Pass a message on to diald and the system logs.
function message () {
[ $FIFO ] && echo "message $*" >$FIFO
logger -p local2.info -t connect "$*"
}

# Initialize the modem. Usually this just resets it.
message "Initializing Modem"
chat TIMEOUT 5 "" $MODEM_INIT TIMEOUT 45 OK ""
if [ $? != 0 ]; then
    message "Failed to initialize modem"
    exit 1
fi

# Dial the remote system.

message "Dialing system"
chat -v \
        TIMEOUT 45 \
        ABORT "NO CARRIER" \
        ABORT BUSY \
        ABORT "NO DIALTONE" \
        ABORT ERROR \
        "" ATDT$PHONE_NUMBER \
        CONNECT ""
case $? in
   0) message Connected;;
   1) message "Chat Error"; exit 1;;
   2) message "Chat Script Error"; exit 1;;
   3) message "Chat Timeout"; exit 1;;
   4) message "No Carrier"; exit 1;;
   5) message "Busy"; exit 1;;
   6) message "No DialTone"; exit 1;;
   7) message "Modem Error"; exit 1;;
   *)
esac

# We're connected try to log in.
if [ $COUNT = "0" ]
then
message "Loggin in"
chat \
        TIMEOUT 5 \
        $USER_CHAT_SEQ \\q$USER_NAME \
        TIMEOUT 45 \
        $PASSWD_CHAT_SEQ $PASSWORD
if [ $? != 0 ]; then
    message "Failed to log in"
    exit 1
fi
fi

# We logged in, try to start up the protocol (provided that the
# user has specified how to do this)

#if [ $PROMPT ]; then
#    message "Starting Comm Protocol"
#    chat TIMEOUT 15 $PROMPT $PROTOCOL_START
#    if [ $? != 0 ]; then
#        message "Prompt not received"
#        exit 1
#    fi
#fi

#if [ $START_ACK ]; then
#    chat TIMEOUT 15 $START_ACK ""
#    if [ $? != 0 ]; then
#       message "Failed to start Protocol"
#       exit 1
#    fi
#fi

# Success!
message "Protocol started"
-----------------------------------------
Mearl Danner
Data Communications/Network Specialist
Email: [EMAIL PROTECTED]
Samford University



-
To unsubscribe from this list: send the line "unsubscribe linux-diald" in
the body of a message to [EMAIL PROTECTED]

Reply via email to