EXPECT-LITE(1)
π expect-lite β EXPECT-LITE(1) (User Commands) π
Okay bestie, welcome to the expect-lite manual page, and it's giving main character energy for your terminal automation era. β¨ No cap, this is the part where you learn the whole vibe. π¦
β¨ NAME β¨
expect-lite β a quick and easy command line automation tool. Periodt, that's the name, and it ate. π
β¨ SYNOPSIS β¨
Two ways to run it, bestie. Lowkey iconic: π
expect-lite [-vv] -c <script> [-r <host>] [CONSTANT=value] [*DIRECTIVE]
[-h|--help]
or
script.elt [-vv] [r=<host>] [CONSTANT=value] [*DIRECTIVE] [-h|--help]
First form is the expect-lite command, second form is running script.elt directly. Both understand -vv, host options, CONSTANT=value, *DIRECTIVE, and -h|--help in the exact positions above. π«Ά
β¨ DESCRIPTION β¨
So here's the tea, bestie: it's written in Expect, and it's designed to directly map an interactive terminal session into an automation script. The scripts use punctuation character(s) at the beginning of each line to indicate the action. Basic expect-lite scripts can be created by simply cutting and pasting text from a terminal window into a script, and adding > < characters. Knowledge of Expect is not required β literally, you can skip that whole era. π§ ngl, that's the vibe check.
Usage, long form:
usage: expect-lite remote_host=<remote_host_IP> cmd_file=<command_file>
[user_dir=<user_dir>] [const1=value1] [*DIRECTIVE]
Or the short form, because we're efficient queens: π
or short form: expect-lite r=<remote_host_IP> c=<command_file>
[d=<user_dir>] [const1=value1] [*DIRECTIVE]
Example, fr fr:
eg. ./expect-lite r=host-008 c=pm_alt.elt d=/local/sw
myvar=myvalue *NOCOLOR
Additional login options: user_name=<username> user_password=<password> π
Example with login, because slay:
eg. ./expect-lite r=host-008 c=pm_alt.elt u=superuser p=mysecret
Additional debug options: -v|-vv|--verbose π
-vβ prints warnings, and infos (i.e. conditionals, dynamic var assignments)-vv|--verboseβ prints warnings and debug (i.e. expect match info)
Example with debug:
eg. ./expect-lite -v r=host-008 c=pm_alt.elt
User defined help options: -h|--help π«Ά
-h|--helpβ displays user defined help text (demarcated by;;;) and variables defined in script which can be overridden by constants on the command line.
π COMMAND SYNOPSIS π
okay bestie, this is just the quick rundown β a little cheat sheet for the girlies who already know expect-lite and just need a nudge to remember stuff. For the full β¨completeβ¨ descriptions you gotta go read the other docs (the html document, specifically). No cap.
πΈ Special Characters πΈ
>β wait for a prompt, then send your string off to the remote host π«Ά>>β send the string to the remote host, no waiting for a prompt, just vibes<β this string/regex MUST come back from the remote host inside the allotted timeout, or the script will FAIL! π<<β literal string that MUST be received (basically<but with no regex evaluation, so it's giving β¨simpleβ¨)-<β the NOT expect. if that string/regex does show up from the remote host, the script FAILS! π~<β the fuzzy expect, for when you're expecting an approximate number (decimal or hex, either one)#β comment lines, they do absolutely nothing and that's iconic;β also comment lines, but these get printed to stdout (for logging purposes, iykyk);<colour> commentβ custom colour comment lines! colour can beblue,ltblue,gray,ltgray,cyan,black,pink,purple,red,green,yellow;;β same as above but no extra newlines get printed (super handy for printing script help);;;β marks the beginning and ending of a block of help text. Help Text is user defined help for a script, and it gets printed when-hor--helpis on the command line@numβ changes the expect timeout to num seconds:numβ sleeps for num seconds. Mili-seconds are supported too, e.g.:1.005is 1005 mili-seconds$var=β static variable assignment at script invocation. Variable names are limited to letters, numbers, and underscore+$var=β dynamic variable assignment+$varβ increment the value of$varby 1 decimal-$varβ decrement the value of$varby 1 decimal=$varβ math functions, performs bitwise and arithmetic operations:<<>>&|^*/%+-(see math functions)=$strβ string math functions, if$stris a string, performs string operations://search/replace/+-(see string math functions in documentation)!β indicates an embedded expect line?β c-style if/then/else in the format?cond?action::else_action. code blocks are supported in the action and else_action statements too, e.g.
?if $i < $n ? [
>send string
<expect string
]::[
>send else string
<expect else string
]
[β While Loop, using code blocks, e.g.
[ $i < $n
+$i
]
Foreach Loop, also using code blocks, where each iteration $item gets assigned the next item in the list. The list must be space delimited, e.g.
$thelist=ab cd ef
[ $item=$thelist
>echo $item
]
%β label, used for jumping to labels~filename [constant=value] [constant=value with spaces]β includes an expect-lite script file, which is super useful for making common variable files, or 'subprograms/subroutines'. You can pass optional parameters which will override (as constants) the variables in the include file. Constant values passed may have spaces, and no quotes are required π
π¦ Directives π¦
*~filenameβ include a fail script, which expect-lite runs only if the main script fails π*/prompt/β set a user defined prompt (defined in regex)*TERM <N>β immediately terminates the script, and returns the value of N. if N isn't specified it returns0*PASSβ immediately terminates the script, and returns0(pass) β¨*FAILβ immediately fails the script, and returns1(fail), unless*NOFAILis set, in which case the script will run to completion, and return1*NOFAILβ the script will run to completion, and returns1if a failure occurred during execution, or0if it passed. (it's a sticky flag, and it can not be unset)**SHELL=<shell>β configuration directive which sets the shell immediately after automatic login to the remote host (see setting the shell)*INTERACTβ a breakpoint which places the user in interact mode, pauses the script, and turns control of the keyboard over to the user π*NOINTERACTβ once set, it will ignore all succeeding breakpoints (*INTERACT). This lets you run a script or scripts in an unattended regression. This can not be unset (it's a sticky flag)*FORK <session>β multiple session support. Directs expect-lite to open a new session and spawns a new shell*SHOW VARSβ debug information, displays all expect-lite variables. Can be used in interact mode.*SHOW ENVβ debug information, displays the expect-lite environment, including state of directives, infinite loop counter, log file name (if used), and environment variables. Can be used in interact mode.*INFINITE_LOOP Nβ infinite loop protection value, sets N as the new value*EOLS LF|*EOLS CRLFβ controls the end of line sequence sent to the remote host, either line feed, or carriage return + line feed*DVPROMPT|*NODVPROMPTβ enable/disable the Dynamic Variable capture method to require a trailing prompt (default=*DVPROMPT)*NOINCLUDEβ once set, it will ignore all succeeding include files (lines starting with~). This was the default behaviour in Library mode (introduced in v4.1). This behaviour is no longer default, and this directive provides a method to get the previous behavior.
π Logging π
Logging encompasses two operations: 1) writing script output to a file, 2) controlling additional messages, such as info, exp_info and warnings. All logging commands, when used on the CLI, will override those inside the script.
*LOG|*NOLOGβ enable/disable logging of standard out and messages to a file. The log file name will be<script_name>.log, saved in the script directory. (see Environment VariableEL_LOG_EXTbelow)*LOG <file_name>|*LOGAPPEND <file_name>β enable logging to a user specified path/file_name. When invoked on the CLI, the specified file_name must end in".log"(or as defined byEL_LOG_EXT) to avoid ambiguity*INFO|*NOINFOβ enable/disable informational messages*EXP_INFO|*NOEXP_INFOβ enable/disable "expected" messages (additionally use the-Vflag to enable)*WARN|*NOWARNβ enable/disable warning messages*DEBUG|*NODEBUGβ enable/disable debug messages*NOCOLORβ disables color on stdout*TIMESTAMP <ISO|YMD|DMY|MDY>β prints Date and Timestamp with milisecond accuracy, for each command sent.ISOis the default. Timestamps will be written to the log file when*LOGis used.*NOTIMESTAMPβ disables timestamp printing
π Environment Variables π
Good news bestie: it is no longer necessary to hand edit the expect-lite script itself. All parameters such as connect_method, login name and password are controlled via shell environment variables. This permits individual customization in a multi user environment. It's recommended to save these values in .expect-literc and source it from .bashrc or .cshrc. If set, the following environment variables will be used:
EL_CONNECT_METHODβ the method expect-lite uses to connect to the remote host. Valid options are:none|telnet|ssh|ssh_key. Default isnoneEL_CONNECT_USERβ user name to use for login on the remote host (telnet|ssh)EL_CONNECT_PASSβ password to use for login on the remote host (telnet|ssh)EL_INFINITE_LOOP=Nβ infinite loop protection value, sets N to the user's default valueEL_DELAY_WAIT_FOR_HOSTβ delay (in ms) to wait for host in Not Expect, and Dynamic Var Capture.100ms is a good value for a local LAN,200ms if you're running across high speed internetEL_REMOTE_HOSTβ name or IP of remote hostEL_CMD_FILEβ name of the expect-lite script to runEL_USER_DIRβ change to this directory upon login before executing the scriptEL_SHELLβ start this shell (defaultbash) when usingEL_CONNECT_METHOD=noneEL_DYN_VAR_PROMPTβ set the Dynamic Variable capture method to require a prompt (default=1). Disable it by setting to0.EL_LOG_EXTβ set the log file name extension string (default=".log") which is appended to the script name when using*LOGwithout a file name argument, or used to detect a log file name on the command lineEL_*β any other shell environment variables starting withEL_will become constants
π§ Debugger (IDE) π§
The debugger performs three primary functions: 1) connecting the user to the remote host or device under test, 2) monitoring special commands prefaced with the escape key for stepping, and other functions, and 3) the debugger will allow expect-lite script lines to be executed by either typing directly or pasting them into the IDE.
The debugger is invoked at a breakpoint by placing the *INTERACT command in the script, or by using instant-interact at anytime during the script execution by pressing ctrl+backslash ^\
<esc>sβ Step, execute the next step in the script<esc>kβ sKip the next step in the script<esc>cβ Continue execution of the script<esc>vβ show Vars, display expect-lite variables and values<esc>eβ show Environment, display the expect-lite environment<esc>0to9β display the next N lines of script<esc>-1to-9β display the last N lines of scriptctrl+dβ Quit & Exit expect-lite<esc>hβ display Help[pasted line(s)]β execute any pasted line(s) from a script into the IDE[type any expect-lite line]β execute any typed expect-lite script line
π AUTHOR π
Written by Craig Miller
π£ REPORTING BUGS π£
Report bugs to <cvmiller at gmail dot com>.
π COPYRIGHT π
Copyright Β© 2008-2015 Craig Miller
Copyright Β© 2005-2007 FreeScale Semiconductor and Craig Miller
License BSD-Style: This is free software: you are free to change and redistribute it. There is NO WARRANTY, to the extent permitted by law.
β SEE ALSO β
The full documentation for expect-lite is maintained as an HTML manual. Please see http://expect-lite.sf.net/ for complete documentation.
and that's the whole page bestie, we ate and left no crumbs π
this was expect-lite version 4.9.0, dated August 2015, filed under EXPECT-LITE(1) β go forth and automate, you absolute main character π¦β¨
π¦ where this page comes from
- ubuntu jammy: expect-lite 4.9.0-0ubuntu1 Β· BSD
- ubuntu noble: expect-lite 4.9.0-0ubuntu2 Β· BSD
- ubuntu questing: expect-lite 4.9.0-0ubuntu2
- ubuntu resolute: expect-lite 4.9.0-0ubuntu3 Β· BSD
- ubuntu stonking: expect-lite 4.9.0-0ubuntu3 Β· BSD
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms