LinuxCommandLibrary

autoexpect

Generate Expect scripts by recording interactive sessions

TLDR

Spawn a shell and generate a script from the session
$ autoexpect
copy
Run a command and generate a script from it
$ autoexpect [command]
copy
Generate a script and save to a specific file
$ autoexpect -f [path/to/file] [command]
copy

SYNOPSIS

autoexpect [options] [command...]

DESCRIPTION

autoexpect watches an interactive session and generates an Expect script that can replay the session automatically. It records user input and program responses, creating a script suitable for automating repetitive interactive tasks.
The generated script is saved as script.exp by default. This script can be modified and reused to automate the recorded interaction.

PARAMETERS

-f file

Save the generated script to the specified file instead of script.exp
-p
Use programmer mode (generate more verbose output)
-t
Set conservative timing

CAVEATS

Generated scripts may need manual editing for robustness. Passwords and sensitive data entered during recording are captured in the script. The timing of interactions may need adjustment for reliable playback.

HISTORY

autoexpect is part of the Expect package, created by Don Libes at NIST. Expect was first released in 1990 and has been widely used for automating interactive applications.

SEE ALSO

expect(1), ssh(1)

> TERMINAL_GEAR

Curated for the Linux community

Copied to clipboard