-->
Previous Table of Contents Next


This chat script makes chat fail if it receives NO CARRIER or BUSY at any point during the script. chat recognizes a number of character and escape sequences, as outlined in Table 29.5.

Table 29.5 Character and Escape Sequences Recognized by chat

Sequence Description

BREAK Used as a reply string, this makes chat send a break to the modem. This special signal normally causes the remote host to change its transmission speed.
‘’ Sends a null string with a single carriage return.
\b The backspace character.
\c Suppresses the newline sent after a reply string and must be at the end of the reply string.
\d Makes chat wait for one second.
\K Another means of specifying a break signal.
\n Sends a newline character.
\N Sends a null character.
\p Pauses for 1/10th of one second.
\q Prevents the string it’s included in from showing in the syslog file.
\r Sends or expects a carriage return.
\s Sends or expects a space character.
\t Sends or expects a tab character.
\\ Sends or expects a backslash character.
\ddd Specifies an ASCII character in octal.
^C Specifies the control character represented by C.


TIP:  You can use the abort string to prevent low-speed calls on your high-speed modem. Configure your modem to return a CARRIER 14400 string when it makes a connection and add abort CARRIER 2400 to your chat script. This way, chat fails if your modem connects at 2400 bps instead of 14400 bps.

Using PPP with >chat

The pppd program has command-line options that control all aspects of the PPP link. The syntax for the pppd command is as follows:


pppd [options] [tty_name] [speed]

Table 29.6 describes the most commonly used options.

Table 29.6 Frequently Used pppd Command-Line Options

Option Description

device Uses the specified device. pppd adds /dev/ to the string if needed. When no device is given, pppd uses the controlling terminal.
speed Sets the modem speed.
asyncmap map Sets the async character map. This map specifies which control characters can’t be sent through the connection and need to be escaped. The map is a 32-bit hex number where each bit represents a character. The 0th bit (00000001) represents character 0 × 00.
auth Requires the remote host to authenticate itself.
connect program Uses the program or shell command to set up the connection. This is where chat is used.
crtscts Uses hardware flow control.
xonxoff Uses software flow control.
defaultroute Makes pppd set a default route to the remote host in your kernel routing table.
disconnect program Runs the specified program after pppd terminates its link.
escape c1 ,c2 ,... Causes the specified characters to be escaped when transmitted. The characters are specified by using the ASCII hex equivalent.
file filename Reads pppd options from the specified file.
lock Uses UUCP-style locking on the serial device.
mru num Sets the maximum receive unit to the specified number.
netmask mask Sets the PPP network interface netmask.
passive Makes pppd wait for a valid connection rather than fail when it can’t initiate a connection immediately.
silent Keeps pppd from initiating a connection. pppd waits for a connection attempt from the remote host instead.

More than 40 other command-line arguments control all aspects of PPP at all levels. Refer to the main page for information about them.


NOTE:  The pppd program demands that the file /etc/ppp/options exist, even if it’s empty. This file is read by pppd and is an excellent place to put options you want pppd to use every time it runs.

You can combine pppd and chat in a number of ways. You can specify all the command-line arguments for both programs on the command line, put the pppd options in a file, or put the chat script in a file. The following is a simple example with everything on the command line:


$ pppd connect ‘chat “” ATDT5551234 ogin: linux2 word: be4me’ \

/dev/cua1 38400 mru 296 lock debug crtscts modem defaultroute

This runs pppd with a simple chat script that dials a phone number and logs the user linux2 in to the remote host. The device, speed, MRU, and a number of other options are included.

At the other extreme, you can place most of the options for pppd in a file and have chat read a script file. The following is the call to pppd :


pppd /dev/cua1 38400 connect ‘chat -f linux1.chat’

The following lines display the contents of the reference file:


# Global PPP Options File

mru 296                            # Set MRU value

lock                               # Use UUCP locking

crtscts                            # Use hardware handshaking

modem                              # Use modem control lines

defaultroute                       # Make PPP set up default route


Previous Table of Contents Next