>>>>> "NW" == Nicholas Waltham <[EMAIL PROTECTED]> writes:

 NW> Hello, Could anyone tell me if there exists a more sofisticated
 NW> chat program which I could use to get diald to try different
 NW> phone numbers.  The scenario is this. Our service provider has

I use this script for about a year.  My provider has about thirty
phones, hehe.  Note that this one requires /usr/lib/diald/login and
/usr/lib/diald/password files containing your login and password (see
and probably change PASSWORD= and USER_NAME= strings).  The script
also logs the connect speed. 

=== Cut connect.multi ===
#!/bin/sh
# 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.
#
# This script has been modified by [EMAIL PROTECTED] to support multiple
# phone-numbers
#
# $Id: connect.multi,v 1.1 1999/02/20 20:42:41 alexm Exp $
#

# Configuration parameters

# The initialization string for your modem

MODEM_INIT="ATZ"

# Dial prefix
DIAL_PREFIX="ATD"

# The phone number to dial
PHONE_NUMBERS="\
123-4567 234-5678 345-6789 456-7890 \
567-8901 678-9012 789-0123 901-2345"

# Phone numbers count
PHONE_NUMBERS_COUNT="`echo $PHONE_NUMBERS | wc -w`"

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

# The string to send in response to the request for your user name.
USER_NAME="`cat /usr/lib/diald/login`"

# 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.
PASSWORD="`cat /usr/lib/diald/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="annex:"
# 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 systems.

N=1

until
        PHONE="`echo $PHONE_NUMBERS | cut -d ' ' -f $N`"
        if [ -z "$PHONE" ]; then 
                exit 1;
        fi
        sleep 3;
        message "Dialing system $PHONE"
        chat -r /tmp/connect-string \
                REPORT CONNECT \
                TIMEOUT 45 \
                ABORT "NO CARRIER" \
                ABORT BUSY \
                ABORT "NO DIAL" \
                ABORT ERROR \
                "" ${DIAL_PREFIX}${PHONE} \
                CONNECT ""
        case $? in
        0) message Connected; /bin/true;;
        1) message "Chat Error"; /bin/false;;
        2) message "Chat Script Error"; /bin/false;;
        3) message "Chat Timeout"; /bin/false;;
        4) message "No Carrier"; /bin/false;;
        5) message "Busy"; /bin/false;;
        6) message "No DialTone"; /bin/false;;
        7) message "Modem Error"; /bin/false;;
        *)
        esac
do 
        N=$[$N + 1];
done

message "`head /tmp/connect-string`"
rm /tmp/connect-string

# We're connected try to log in.
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

# 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"

=== Cut connect.milti ===

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

Reply via email to