📄 chat.8
字号:
.LPThe report strings to no change the completion code of the program..LPThese "report" strings may be specified in the script using the \fIREPORT\fRsequence. It is written in the script as in the following example:.IPREPORT CONNECT ABORT BUSY '' ATDT5551212 CONNECT '' ogin: account.LPThis sequence will expect nothing; and then send the stringATDT5551212 to dial the telephone. The expected string is\fICONNECT\fR. If the string \fICONNECT\fR is received the remainderof the script is executed. In addition the program will write to theexpect-file the string "CONNECT" plus any characters which follow itsuch as the connection rate..SH CLR_REPORT STRINGSThis sequence allows for clearing previously set \fBREPORT\fR strings.\fBREPORT\fR strings are kept in an array of a pre-determined size (atcompilation time); \fBCLR_REPORT\fR will reclaim the space for clearedentries so that new strings can use that space..SH ECHOThe echo options controls whether the output from the modem is echoedto \fIstderr\fR. This option may be set with the \fI-e\fR option, butit can also be controlled by the \fIECHO\fR keyword. The "expect-send"pair \fIECHO\fR \fION\fR enables echoing, and \fIECHO\fR \fIOFF\fRdisables it. With this keyword you can select which parts of theconversation should be visible. For instance, with the followingscript:.IPABORT 'BUSY'.brABORT 'NO CARRIER'.br'' ATZ.brOK\\r\\n ATD1234567.br\\r\\n \\c.brECHO ON.brCONNECT \\c.brogin: account.LPall output resulting from modem configuration and dialing is not visible,but starting with the \fICONNECT\fR (or \fIBUSY\fR) message, everythingwill be echoed..SH HANGUPThe HANGUP options control whether a modem hangup should be consideredas an error or not. This option is useful in scripts for diallingsystems which will hang up and call your system back. The HANGUPoptions can be \fBON\fR or \fBOFF\fR..brWhen HANGUP is set OFF and the modem hangs up (e.g., after the firststage of logging in to a callback system), \fBchat\fR will continuerunning the script (e.g., waiting for the incoming call and secondstage login prompt). As soon as the incoming call is connected, youshould use the \fBHANGUP ON\fR directive to reinstall normal hang upsignal behavior. Here is an (simple) example script:.IPABORT 'BUSY'.br'' ATZ.brOK\\r\\n ATD1234567.br\\r\\n \\c.brCONNECT \\c.br\'Callback login:' call_back_ID.brHANGUP OFF.brABORT "Bad Login".br\'Callback Password:' Call_back_password.brTIMEOUT 120.brCONNECT \\c.brHANGUP ON.brABORT "NO CARRIER".brogin:--BREAK--ogin: real_account.br\fIetc ...\fR.LP.SH TIMEOUTThe initial timeout value is 45 seconds. This may be changed using the \fB-t\fRparameter..LPTo change the timeout value for the next expect string, the followingexample may be used:.IPATZ OK ATDT5551212 CONNECT TIMEOUT 10 ogin:--ogin: TIMEOUT 5 assword: hello2u2.LPThis will change the timeout to 10 seconds when it expects the login:prompt. The timeout is then changed to 5 seconds when it looks for thepassword prompt..LPThe timeout, once changed, remains in effect until it is changed again..SH SENDING EOTThe special reply string of \fIEOT\fR indicates that the chat programshould send an EOT character to the remote. This is normally theEnd-of-file character sequence. A return character is not sentfollowing the EOT..PRThe EOT sequence may be embedded into the send string using thesequence \fI^D\fR..SH GENERATING BREAKThe special reply string of \fIBREAK\fR will cause a break conditionto be sent. The break is a special signal on the transmitter. Thenormal processing on the receiver is to change the transmission rate.It may be used to cycle through the available transmission rates onthe remote until you are able to receive a valid login prompt..PRThe break sequence may be embedded into the send string using the\fI\\K\fR sequence..SH ESCAPE SEQUENCESThe expect and reply strings may contain escape sequences. All of thesequences are legal in the reply string. Many are legal in the expect.Those which are not valid in the expect sequence are so indicated..TP.B ''Expects or sends a null string. If you send a null string then it will stillsend the return character. This sequence may either be a pair of apostropheor quote characters..TP.B \\\\brepresents a backspace character..TP.B \\\\cSuppresses the newline at the end of the reply string. This is the onlymethod to send a string without a trailing return character. It mustbe at the end of the send string. For example,the sequence hello\\c will simply send the characters h, e, l, l, o..I (not valid in expect.).TP.B \\\\dDelay for one second. The program uses sleep(1) which will delay to amaximum of one second..I (not valid in expect.).TP.B \\\\KInsert a BREAK.I (not valid in expect.).TP.B \\\\nSend a newline or linefeed character..TP.B \\\\NSend a null character. The same sequence may be represented by \\0..I (not valid in expect.).TP.B \\\\pPause for a fraction of a second. The delay is 1/10th of a second..I (not valid in expect.).TP.B \\\\qSuppress writing the string to the SYSLOG file. The string ?????? iswritten to the log in its place..I (not valid in expect.).TP.B \\\\rSend or expect a carriage return..TP.B \\\\sRepresents a space character in the string. This may be used when itis not desirable to quote the strings which contains spaces. Thesequence 'HI TIM' and HI\\sTIM are the same..TP.B \\\\tSend or expect a tab character..TP.B \\\\TSend the phone number string as specified with the \fI-T\fR option.I (not valid in expect.).TP.B \\\\USend the phone number 2 string as specified with the \fI-U\fR option.I (not valid in expect.).TP.B \\\\\\\\Send or expect a backslash character..TP.B \\\\dddCollapse the octal digits (ddd) into a single ASCII character and send thatcharacter..I (some characters are not valid in expect.).TP.B \^^CSubstitute the sequence with the control character represented by C.For example, the character DC1 (17) is shown as \^^Q..I (some characters are not valid in expect.).SH ENVIRONMENT VARIABLESEnvironment variables are available within chat scripts, if the \fI-E\fRoption was specified in the command line. The metacharacter \fI$\fR is usedto introduce the name of the environment variable to substitute. If thesubstition fails, because the requested environment variable is not set,\fInothing\fR is replaced for the variable..SH TERMINATION CODESThe \fIchat\fR program will terminate with the following completioncodes..TP.B 0The normal termination of the program. This indicates that the scriptwas executed without error to the normal conclusion..TP.B 1One or more of the parameters are invalid or an expect string was toolarge for the internal buffers. This indicates that the program as notproperly executed..TP.B 2An error occurred during the execution of the program. This may be dueto a read or write operation failing for some reason or chat receivinga signal such as SIGINT..TP.B 3A timeout event occurred when there was an \fIexpect\fR string withouthaving a "-subsend" string. This may mean that you did not program thescript correctly for the condition or that some unexpected event hasoccurred and the expected string could not be found..TP.B 4The first string marked as an \fIABORT\fR condition occurred..TP.B 5The second string marked as an \fIABORT\fR condition occurred..TP.B 6The third string marked as an \fIABORT\fR condition occurred..TP.B 7The fourth string marked as an \fIABORT\fR condition occurred..TP.B ...The other termination codes are also strings marked as an \fIABORT\fRcondition..LPUsing the termination code, it is possible to determine which eventterminated the script. It is possible to decide if the string "BUSY"was received from the modem as opposed to "NO DIAL TONE". While thefirst event may be retried, the second will probably have littlechance of succeeding during a retry..SH SEE ALSOAdditional information about \fIchat\fR scripts may be found with UUCPdocumentation. The \fIchat\fR script was taken from the ideas proposedby the scripts used by the \fIuucico\fR program..LPuucico(1), uucp(1).SH COPYRIGHTThe \fIchat\fR program is in public domain. This is not the GNU publiclicense. If it breaks then you get to keep both pieces.
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -