EXPECT(1)EXPECT(1)
NAME
at, drain, expect, pass – dialer scripting tools
SYNOPSIS
DESCRIPTION
These commands are used to write telephone dialing
scripts, mostly for PPP sessions. They all expect standard input and
output to be connected to a communications device, e.g,
a serial line to a modem. They communicate with the user using
set the timeout to
don’t write to
set the timeout to
ignore case when doing the matches.
don’t write to
EXAMPLE
The following
#!/bin/rc
dev=/dev/eia1
telno=18005551212
fn initfn {
dial/drain
echo +++
dial/at zh0
}
fn dialfn {
dial/drain
dial/at dt^$telno
}
{
# set up uart
if( test -e $dev^ctl ){
echo -n b^$baud
echo -n m1 # cts/rts flow control
echo -n q64000 # big buffer
echo -n n1 # nonblocking writes
echo -n r1 # rts on
echo -n d1 # dtr on
echo -n c1 # handup when we lose dcd
} > $dev^ctl
# get the modem's attention
while( ! initfn )
sleep 1
# dial
while( ! dialfn )
sleep 30
if( ! dial/expect -it 60 'username:' ){
echo can''t connect >[1=2]
exit connect
}
dial/pass
if( ! dial/expect -it 60 'password:' ){
echo can''t connect >[1=2]
exit connect
}
dial/pass
if( ! dial/expect -t 60 'ppp or telnet:' ){
echo can''t connect >[1=2]
exit connect
}
echo ppp
dial/expect -t 5 something
echo connected >[1=2]
# start ppp
ip/ppp $primary -f
} < $dev > $dev