LinuxCommandLibrary

chat

automated modem and serial device conversation

TLDR

Execute a chat script directly

$ chat '[expect_send_pairs]'
copy
Execute a chat script from a file
$ chat -f '[path/to/chat_script]'
copy
Set a custom timeout
$ chat -t [timeout_in_seconds] '[expect_send_pairs]'
copy
Enable verbose output to syslog
$ chat -v '[expect_send_pairs]'
copy
Use a report file for logging
$ chat -r [path/to/report_file] '[expect_send_pairs]'
copy
Dial a phone number using a variable
$ chat -T '[phone_number]' '"ATDT\\T CONNECT"'
copy
Include an abort condition
$ chat 'ABORT "[error_string]" [expect_send_pairs]'
copy

SYNOPSIS

chat [options] script

DESCRIPTION

chat automates conversations with modems and serial devices by exchanging expect-send string pairs. It waits for an expected string from the device, then sends a response, repeating this process through a scripted sequence.
The primary use case is establishing PPP (Point-to-Point Protocol) connections over serial lines and modems. A typical chat script initializes the modem with AT commands, dials a phone number, waits for a CONNECT response, and handles login sequences. Abort strings can be defined to terminate the script on error conditions like BUSY or NO CARRIER.
chat is part of the ppp package and is typically invoked by pppd rather than run directly. Scripts can be specified inline on the command line or loaded from a file.

PARAMETERS

-f file

Read script from file
-t seconds
Timeout for expecting responses
-v
Verbose logging to syslog
-r file
Log specific strings to report file
-T string
Substitute \T in script with string
-V
Log all conversation to stderr

SCRIPT SYNTAX

ABORT string

Abort if string is received
TIMEOUT seconds
Set timeout for next expect
REPORT string
Log string to report file

CAVEATS

Primarily used for legacy modem/PPP connections. Timing is critical; adjust timeouts for slow devices. Escape sequences may need proper quoting.

SEE ALSO

pppd(8), expect(1)

> TERMINAL_GEAR

Curated for the Linux community

Copied to clipboard

> TERMINAL_GEAR

Curated for the Linux community