LinuxCommandLibrary

expect

Execute an expect script from file

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.
Commonly used for automating SSH logins, FTP sessions, and other interactive programs.

PARAMETERS

-c commands

Execute commands directly
-i
Interactive mode (REPL)
-f file
Read commands from file
-d
Debug mode

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)

Copied to clipboard