Subversion Repositories planix.SVN

Rev

Rev 2 | Details | Compare with Previous | Last modification | View Log | RSS feed

Rev Author Line No. Line
2 - 1
.TH EXPECT 1
2
.SH NAME
3
at, drain, expect, pass \- dialer scripting tools
4
.SH SYNOPSIS
5
.B dial/at
6
[
7
.B -q
8
] [
9
.B -t
10
.I seconds
11
]
12
atcommand
13
.br
14
.B dial/expect
15
[
16
.B -iq
17
] [
18
.B -t
19
.I seconds
20
]
21
.I goodstring
22
[
23
.IR badstring ...
24
]
25
.br
26
.B dial/drain
27
.br
28
.B dial/pass
29
[
30
.B -q
31
]
32
.SH DESCRIPTION
33
These commands are used to write telephone dialing
34
scripts, mostly for PPP sessions.  They all expect standard input and
35
output to be connected to a communications device, e.g,
36
a serial line to a modem.  They communicate with the user using
37
.BR /dev/cons .
38
.PP
39
.I At
40
sends
41
.B atcommand
42
to the modem prefixed with the string
43
.BR at .
44
It then reads from the modem expecting an AT response. 
45
.I At
46
will return success if it gets and
47
.B OK
48
of
49
.B CONNECT
50
response.  Otherwise it will return the response as an
51
error status.  The options are:
52
.TP
53
.B -t
54
set the timeout to
55
.IR seconds .
56
The default is 300.
57
.TP
58
.B -q
59
don't write to
60
.B /dev/cons
61
what is read from standard in.  The default is
62
to copy everything through.
63
.PD
64
.PP
65
.I Expect
66
reads standard input looking for one of the strings given
67
as arguments.  Reading the first string causes a successul exit
68
status.  Reading any of the others causes an exit status equal to
69
the string.  The command also terminates on a timeout.  The options
70
are:
71
.TP
72
.B -t
73
set the timeout to
74
.IR seconds .
75
The default is 300.
76
.TP
77
.B -i
78
ignore case when doing the matches.
79
.TP
80
.B -q
81
don't write to
82
.B /dev/cons
83
what is read from standard in.  The default is
84
to copy everything through.
85
.PD
86
.PP
87
.I Pass
88
copies input from
89
.B /dev/cons
90
to standard output.
91
It terminates on a newline.  The only flag is
92
.B -q
93
and means the same as it does for
94
.IR expect .
95
.PP
96
.I Drain
97
discards any input waiting on standard input.  It
98
is used to sync up the stream at the start of dialing
99
or after an error.
100
.SH EXAMPLE
101
The following
102
.B rc
103
script dials out through a Hayes compatible modem on
104
.B /dev/eia1
105
and lets the user type in a user name and password
106
before starting
107
.BR ppp .
108
.EX
109
#!/bin/rc
110
dev=/dev/eia1
111
telno=18005551212
112
 
113
fn initfn {
114
	dial/drain
115
	echo +++
116
	dial/at zh0
117
}
118
 
119
fn dialfn {
120
	dial/drain
121
	dial/at dt^$telno
122
}
123
{
124
	# set up uart
125
	if( test -e $dev^ctl ){
126
		echo -n b^$baud
127
		echo -n m1	# cts/rts flow control
128
		echo -n q64000	# big buffer
129
		echo -n n1	# nonblocking writes
130
		echo -n r1	# rts on
131
		echo -n d1	# dtr on
132
		echo -n c1	# handup when we lose dcd
133
	} > $dev^ctl
134
 
135
	# get the modem's attention
136
	while( ! initfn )
137
		sleep 1
138
 
139
	# dial
140
	while( ! dialfn )
141
		sleep 30
142
 
143
	if( ! dial/expect -it 60 'username:' ){
144
		echo can''t connect >[1=2]
145
		exit connect
146
	}
147
	dial/pass
148
	if( ! dial/expect -it 60 'password:' ){
149
		echo can''t connect >[1=2]
150
		exit connect
151
	}
152
	dial/pass
153
	if( ! dial/expect -t 60 'ppp or telnet:' ){
154
		echo can''t connect >[1=2]
155
		exit connect
156
	}
157
	echo ppp
158
	dial/expect -t 5 something
159
	echo connected >[1=2]
160
 
161
	# start ppp
162
	ip/ppp $primary -f
163
} < $dev > $dev
164
.EE
165
.SH FILES
166
.B /rc/bin/ipconf/*
167
example dialer scripts for ppp
168
.SH SOURCE
169
.B /sys/src/cmd/dial/*.c
170
.SH SEE ALSO
171
.IR ppp (8),
172
.IR telco (4)