]> git.ozlabs.org Git - ppp.git/blob - chat/chat.8
fix for linux compilation
[ppp.git] / chat / chat.8
1 .\" -*- nroff -*-
2 .\" manual page [] for chat 1.8
3 .\" $Id: chat.8,v 1.1 1995/04/28 05:27:25 paulus Exp $
4 .\" SH section heading
5 .\" SS subsection heading
6 .\" LP paragraph
7 .\" IP indented paragraph
8 .\" TP hanging label
9 .TH CHAT 8 "17 April 1994" "Chat Version 1.8"
10 .SH NAME
11 chat \- Automated conversational script with a modem
12 .SH SYNOPSIS
13 .B chat
14 [
15 .I options
16 ]
17 .I script
18 .SH DESCRIPTION
19 .LP
20 The \fIchat\fR program defines a conversational exchange between the
21 computer and the modem. Its primary purpose is to establish the
22 connection between the Point-to-Point Protocol Daemon (\fIpppd\fR) and
23 the remote's \fIpppd\fR process.
24 .SH OPTIONS
25 .TP
26 .B -f \fI<chat file>
27 Read the chat script from the chat \fIfile\fR. The use of this option
28 is mutually exclusive with the chat script parameters. The user must
29 have read access to the file. Multiple lines are permitted in the
30 file. Space or horizontal tab characters should be used to separate
31 the strings.
32 .TP
33 .B -l \fI<lock file>
34 Perform the UUCP style locking using the indicated lock file.
35 .IP
36 If the file could not be created then the \fIchat\fR program will
37 fail. The lock file will be deleted only if the \fIchat\fR program
38 fails to perform the script for any reason. If the script is
39 successful the lock file will be left on the disk. It is expected that
40 the lock file will be deleted when the \fIpppd\fR process no longer
41 wishes to use the serial device.
42 .IP
43 The use of a lock file with 
44 .I chat
45 and 
46 \fIpppd\fR\'s
47 .I lock
48 option should not be used at the same time. They are mutually
49 exclusive options and will cause one or the other program to fail to
50 achieve the required lock if you use both.
51 .TP
52 .B -t \fI<timeout>
53 Set the timeout for the expected string to be received. If the string
54 is not received within the time limit then the reply string is not
55 sent. An alternate reply may be sent or the script will fail if there
56 is no alternate reply string. A failed script will cause the
57 \fIchat\fR program to terminate with a non-zero error code.
58 .TP
59 .B -v
60 Request that the \fIchat\fR script be executed in a verbose mode. The
61 \fIchat\fR program will then log all text received from the modem and
62 the output strings which it sends to the SYSLOG.
63 .TP
64 .B script
65 If the script is not specified in a file with the \fI-f\fR option then
66 the script is included as parameters to the \fIchat\fR program.
67 .SH CHAT SCRIPT
68 .LP
69 The \fIchat\fR script defines the communications.
70 .LP
71 A script consists of one or more "expect-send" pairs of strings,
72 separated by spaces, with an optional "subexpect-subsend" string pair,
73 separated by a dash as in the following example:
74 .IP
75 ogin:-BREAK-ogin: ppp ssword: hello2u2
76 .LP
77 This line indicates that the \fIchat\fR program should expect the string
78 "ogin:". If it fails to receive a login prompt within the time interval
79 allotted, it is to send a break sequence to the remote and then expect the
80 string "ogin:". If the first "ogin:" is received then the break sequence is
81 not generated.
82 .LP
83 Once it received the login prompt the \fIchat\fR program will send the string ppp
84 and then expect the prompt "ssword:". When it receives the prompt for the
85 password, it will send the password hello2u2.
86 .LP
87 A carriage return is normally sent following the reply string. It is not
88 expected in the "expect" string unless it is specifically requested by using
89 the \\r character sequence.
90 .LP
91 The expect sequence should contain only what is needed to identify the
92 string. Since it is normally stored on a disk file, it should not contain
93 variable information. It is generally not acceptable to look for time
94 strings, network identification strings, or other variable pieces of data as
95 an expect string.
96 .LP
97 To help correct for characters which may be corrupted during the initial
98 sequence, look for the string "ogin:" rather than "login:". It is possible
99 that the leading "l" character may be received in error and you may never
100 find the string even though it was sent by the system. For this reason,
101 scripts look for "ogin:" rather than "login:" and "ssword:" rather than
102 "password:".
103 .LP
104 A very simple script might look like this:
105 .IP
106 ogin: ppp ssword: hello2u2
107 .LP
108 In other words, expect ....ogin:, send ppp, expect ...ssword:, send hello2u2.
109 .LP
110 In actual practice, simple scripts are rare. At the vary least, you
111 should include sub-expect sequences should the original string not be
112 received. For example, consider the following script:
113 .IP
114 ogin:--ogin: ppp ssowrd: hello2u2
115 .LP
116 This would be a better script than the simple one used earlier. This would look
117 for the same login: prompt, however, if one was not received, a single
118 return sequence is sent and then it will look for login: again. Should line
119 noise obscure the first login prompt then sending the empty line will
120 usually generate a login prompt again.
121 .SH ABORT STRINGS
122 Many modems will report the status of the call as a string. These
123 strings may be \fBCONNECTED\fR or \fBNO CARRIER\fR or \fBBUSY\fR. It
124 is often desirable to terminate the script should the modem fail to
125 connect to the remote. The difficulty is that a script would not know
126 exactly which modem string it may receive. On one attempt, it may
127 receive \fBBUSY\fR while the next time it may receive \fBNO CARRIER\fR.
128 .LP
129 These "abort" strings may be specified in the script using the \fIABORT\fR
130 sequence. It is written in the script as in the following example:
131 .IP
132 ABORT BUSY ABORT 'NO CARRIER' '' ATZ OK ATDT5551212 CONNECT
133 .LP
134 This sequence will expect nothing; and then send the string ATZ. The
135 expected response to this is the string \fIOK\fR. When it receives \fIOK\fR,
136 the string ATDT5551212 to dial the telephone. The expected string is
137 \fICONNECT\fR. If the string \fICONNECT\fR is received the remainder of the
138 script is executed. However, should the modem find a busy telephone, it will
139 send the string \fIBUSY\fR. This will cause the string to match the abort
140 character sequence. The script will then fail because it found a match to
141 the abort string. If it received the string \fINO CARRIER\fR, it will abort
142 for the same reason. Either string may be received. Either string will
143 terminate the \fIchat\fR script.
144 .SH TIMEOUT
145 The initial timeout value is 45 seconds. This may be changed using the \fB-t\fR
146 parameter.
147 .LP
148 To change the timeout value for the next expect string, the following
149 example may be used:
150 .IP
151 ATZ OK ATDT5551212 CONNECT TIMEOUT 10 ogin:--ogin: TIMEOUT 5 assowrd: hello2u2
152 .LP
153 This will change the timeout to 10 seconds when it expects the login:
154 prompt. The timeout is then changed to 5 seconds when it looks for the
155 password prompt.
156 .LP
157 The timeout, once changed, remains in effect until it is changed again.
158 .SH SENDING EOT
159 The special reply string of \fIEOT\fR indicates that the chat program
160 should send an EOT character to the remote. This is normally the
161 End-of-file character sequence. A return character is not sent
162 following the EOT.
163 .PR
164 The EOT sequence may be embedded into the send string using the
165 sequence \fI^D\fR.
166 .SH GENERATING BREAK
167 The special reply string of \fIBREAK\fR will cause a break condition
168 to be sent. The break is a special signal on the transmitter. The
169 normal processing on the receiver is to change the transmission rate.
170 It may be used to cycle through the available transmission rates on
171 the remote until you are able to receive a valid login prompt.
172 .PR
173 The break sequence may be embedded into the send string using the
174 \fI\\K\fR sequence.
175 .SH ESCAPE SEQUENCES
176 The expect and reply strings may contain escape sequences. All of the
177 sequences are legal in the reply string. Many are legal in the expect.
178 Those which are not valid in the expect sequence are so indicated.
179 .TP
180 .B ''
181 Expects or sends a null string. If you send a null string then it will still
182 send the return character. This sequence may either be a pair of apostrophe
183 or quote characters.
184 .TP
185 .B \\\\b
186 represents a backspace character.
187 .TP
188 .B \\\\c
189 Suppresses the newline at the end of the reply string. This is the only
190 method to send a string without a trailing return character. It must
191 be at the end of the send string. For example,
192 the sequence hello\\c will simply send the characters h, e, l, l, o.
193 .I (not valid in expect.)
194 .TP
195 .B \\\\d
196 Delay for one second. The program uses sleep(1) which will delay to a
197 maximum of one second.
198 .I (not valid in expect.)
199 .TP
200 .B \\\\K
201 Insert a BREAK
202 .I (not valid in expect.)
203 .TP
204 .B \\\\n
205 Send a newline or linefeed character.
206 .TP
207 .B \\\\N
208 Send a null character. The same sequence may be represented by \\0.
209 .I (not valid in expect.)
210 .TP
211 .B \\\\p
212 Pause for a fraction of a second. The delay is 1/10th of a second.
213 .I (not valid in expect.)
214 .TP
215 .B \\\\q
216 Suppress writing the string to the SYSLOG file. The string ?????? is
217 written to the log in its place.
218 .I (not valid in expect.)
219 .TP
220 .B \\\\r
221 Send or expect a carriage return.
222 .TP
223 .B \\\\s
224 Represents a space character in the string. This may be used when it
225 is not desirable to quote the strings which contains spaces. The
226 sequence 'HI TIM' and HI\\sTIM are the same.
227 .TP
228 .B \\\\t
229 Send or expect a tab character.
230 .TP
231 .B \\\\\\\\
232 Send or expect a backslash character.
233 .TP
234 .B \\\\ddd
235 Collapse the octal digits (ddd) into a single ASCII character and send that
236 character.
237 .I (some characters are not valid in expect.)
238 .TP
239 .B \^^C
240 Substitute the sequence with the control character represented by C.
241 For example, the character DC1 (17) is shown as \^^Q.
242 .I (some characters are not valid in expect.)
243 .SH SEE ALSO
244 Additional information about \fIchat\fR scripts may be found with UUCP
245 documentation. The \fIchat\fR script was taken from the ideas proposed by the
246 scripts used by the \fIuucico\fR program.
247 .LP
248 uucico(1), uucp(1)
249 .SH COPYRIGHT
250 The \fIchat\fR program is in public domain. This is not the GNU public
251 license. If it breaks then you get to keep both pieces.