LinuxCommandLibrary
GitHubF-DroidGoogle Play Store

expect

automate interactive applications with scripted responses

TLDR

Execute an expect script from file
$ expect [path/to/file]
copy
Execute a specified expect script
$ expect -c "[commands]"
copy
Enter interactive REPL
$ expect -i
copy

SYNOPSIS

expect [options] [script] [arguments]

DESCRIPTION

expect automates interactive applications by scripting responses to expected prompts. It spawns processes and responds to their output based on pattern matching.The tool uses Tcl scripting language with expect-specific commands like spawn, expect, and send. Scripts can handle multiple response patterns, timeouts, and conditional logic. This enables automation of programs that require interactive input like passwords, confirmations, or menu selections.Commonly used for automating SSH logins, FTP sessions, database setup scripts, and other interactive programs. While powerful, modern alternatives like SSH keys, API tokens, and configuration management tools are often preferred for security.

PARAMETERS

-c commands

Execute the given Tcl/Expect commands before the script runs.
-i
Interactive mode (REPL). Also implied when stdin is a terminal.
-f FILE
Read the command script from FILE.
-b FILE
Read the script line-by-line (buffered mode) — useful for very long scripts.
-d
Enable diagnostic output (command tracing).
-D [N]
Enter the interactive debugger (on first prompt or after N expect calls).
-v
Print Expect version and exit.
--
End of options; following arguments are passed to the script in `$argv`.

INSTALL

sudo apt install expect
copy
sudo dnf install expect
copy
sudo pacman -S expect
copy
sudo apk add expect
copy
sudo zypper install expect
copy
brew install expect
copy
nix profile install nixpkgs#expect
copy

CAVEATS

Uses Tcl scripting language. Sending passwords in scripts has security implications. Consider SSH keys or other authentication methods when possible.

SEE ALSO

autoexpect(1), tcl(1), ssh(1)

Braincup
Open source brain training for math, memory and focus
Braincup mini-games
41 mini-games · Apache-2.0
No ads · No tracking
Play in browser
Download Braincup on the App StoreGet Braincup on Google PlayGet Braincup on F-Droid
276 stars
From the maker of Linux Command Library
Copied to clipboard
Braincup
Open source brain training for math, memory and focus. 41 mini-games, from mental arithmetic to Sudoku, N-Back and Solo Chess.
Apache-2.0 licensed · No ads · No tracking · No account
From the maker of Linux Command Library
Download Braincup on the App StoreGet Braincup on Google PlayGet Braincup on F-Droid