chat
No standard "chat" command exists in Linux
TLDR
Execute a chat script directly
Execute a chat script from a file
Set a custom timeout (in seconds) for expecting a response
Enable verbose output to log the conversation to syslog
Use a report file to log specific strings received during the conversation
Dial a phone number using a variable, substituting \T in the script
Include an abort condition if a specific string is received
SYNOPSIS
chat [options] expect send ...
PARAMETERS
-v
Enable verbose logging to stderr
-e
Exit after script completion (hangup)
-E
Convert expect strings to uppercase
-t timeout
Set timeout in seconds (default 45)
-f file
Read script from file instead of args
-r report
Log failed expects to report file
-s
Do not use stderr (stdout/stdin only)
-S
Do not log to syslog
-T phone
Substitute \d with phone number in send
--help
Display usage summary
-V
Print version info
DESCRIPTION
The chat utility is a lightweight tool for automating conversations with interactive programs, such as modems during dial-up or PPP sessions. It interprets a script of alternating expect and send strings: it waits for specific output (expect) and responds with predefined input (send). Empty expect strings send immediately, while timeouts and ABORT conditions handle failures.
Commonly invoked by pppd via connect '/usr/sbin/chat -v -f /etc/chatscripts/myisp', it enables scripted modem control (e.g., AT commands like ATZ for reset, ATDT for dialing). Supports logging, verbose output, and custom timeouts. Unlike full expect, it's simpler, non-branching, and ideal for linear dialogues.
Key strengths: reliable for PPPoE/dial-up setups, low overhead. Limitations: basic string matching (no regex unless extended), no complex logic. Widely used in legacy networking, embedded systems, and custom serial automation.
CAVEATS
Basic string matching only (no regex/Wildcards limited); linear scripts, no branching. Use double quotes for sends with vars. Modems must support Hayes AT cmds. Deprecated for modern broadband.
SCRIPT FORMAT
Pairs like: '' ATZ OK 'ATDT\T' CONNECT
\T expands to -T phone; -- for delays; ABORT 'NO CARRIER' to fail on error.
PPP EXAMPLE
/etc/ppp/peers/myisp:
connect '/usr/sbin/chat -v -t60 -f /etc/chatscripts/gprs'
Script: ABORT 'NO CARRIER' '' ATZ OK AT+CGDCONT=1,"IP","apn" OK ATD*99# CONNECT ''
HISTORY
Developed by Al Longyear in 1994 for Linux PPP daemon integration. Part of ppp package; evolved minimally, remains stable for serial/PPP use into 2020s.


