1#!/bin/sh
2###################################################################
3#
4# These parameters control the attack dialing sequence.
5#
6# Maximum number of attempts to reach the telephone number(s)
7MAX_ATTEMPTS=10
8
9# Delay between each of the attempts. This is a parameter to sleep
10# so use "15s" for 15 seconds, "1m" for 1 minute, etc.
11SLEEP_DELAY=15s
12
13###################################################################
14#
15# This is a list of telephone numbers. Add new numbers if you wish
16# and see the function 'callall' below for the dial process.
17PHONE1=555-1212
18PHONE2=411
19
20###################################################################
21#
22# If you use the ppp-on script, then these are passed to this routine
23# automatically. There is no need to define them here. If not, then
24# you will need to set the values.
25#
26ACCOUNT=my_account_name
27PASSWORD=my_password
28
29###################################################################
30#
31# Function to initialize the modem and ensure that it is in command
32# state. This may not be needed, but it doesn't hurt.
33#
34function initialize
35{
36    chat -v TIMEOUT 3 '' AT 'OK-+++\c-OK'
37    return
38}
39
40###################################################################
41#
42# Script to dial a telephone
43#
44function callnumber
45{
46chat -v							\
47	ABORT		'\nBUSY\r'			\
48	ABORT		'\nNO ANSWER\r'			\
49	ABORT		'\nRINGING\r\n\r\nRINGING\r'	\
50	''		ATDT$1				\
51	CONNECT		''				\
52	ogin:--ogin:	$ACCOUNT			\
53	assword:	$PASSWORD
54#
55# If the connection was successful then end the whole script with a
56# success.
57#
58    if [ "$?" = "0" ]; then
59       exit 0
60    fi
61
62    return
63}
64
65###################################################################
66#
67# Script to dial any telephone number
68#
69function callall
70{
71#   echo "dialing attempt number: $1" >/dev/console
72    callnumber $PHONE1
73#    callnumber $PHONE2
74}
75
76###################################################################
77#
78# Initialize the modem to ensure that it is in the command state
79#
80initialize
81if [ ! "$?" = "0" ]; then
82   exit 1
83fi
84
85#
86# Dial telephone numbers until one answers
87#
88attempt=0
89while : ; do
90    attempt=`expr $attempt + 1`
91    callall $attempt
92    if [ "$attempt" = "$MAX_ATTEMPTS" ]; then
93	exit 1
94    fi	
95    sleep "$SLEEP_DELAY"
96done
97