Subject: Re: PPP/Chat redial capability?
To: None <tooleym@douglas.bc.ca>
From: Jeremy Cooper <jeremy@broder.com>
List: current-users
Date: 01/15/1998 17:03:48
On Thu, 15 Jan 1998 tooleym@douglas.bc.ca wrote:
> [ would like pppd or chat to redial a few times before giving up ]
Pppd allows you to specify any program or shell script to be used as the
'connect' program. It needn't be chat itself. This is very handy for
exotic dial-in cases like SecureID (tm) and other dynamic authentication
procedures. It also works well for special needs like yours.
I would write a shell script like this:
#!/bin/sh
CHAT=/usr/bin/chat
NUMBER=18005551212
TRYREDIAL=3
STATUS=
#
# Exit codes from chat.
#
BUSY=4
NOCARRIER=5
while [ ${TRYREDIAL} -gt 0 ]; do
${CHAT} ABORT BUSY ABORT NO CARRIER '' '\rAT' 'OK' "ATDT$NUMBER" #etc
STATUS=$?
if [ ${STATUS} = 0 ]; then
# Successful connection
exit 0
elif [ ${STATUS} = ${BUSY} ]; then
REDIAL=`expr $TRYREDIAL - 1`
elif [ ${STATUS} = ${NOCARRIER} ]; then
exit 1
else
# Some other error occurred.
exit 1
fi
done
#
# Redial failed with busy on all attempts.
#
exit 1
Make this script executable and supply it as the value for the 'connect'
command line argument to pppd. This works as a chat script because:
1) Under normal operation, the only stdin/stdout traffic will occur from
'chat' itself.
2) It exits with a return value of 0 upon a successful connection, and 1
otherwise.
-J