expect-lite - a quick and easy command line automation tool
expect-lite [-vv] -c <script> [-r <host>] [CONSTANT=value]
expect-lite [-vv] c=<script> [r=<host>] [CONSTANT=value]
Written in Expect, it is designed to directly map an interactive
terminal session into an automation script. expect-lite 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.
usage: expect-lite remote_host=<remote_host_IP> cmd_file=<command_file>
or short form: expect-lite r=<remote_host_IP> c=<command_file>
[d=<user_dir>] [const1=value1] eg. ./expect-lite r=host-008
c=pm_alternation.elt d=/local/craig/SW_6_Mar/sw myvar=myvalue
additional login options: user_name=<username> user_password=<password>
eg. ./expect-lite r=host-008 c=pm_alternation.elt u=superuser
additional debug options: -v|-vv|--verbose
-v prints warnings, and infos (i.e. conditionals, dynamic var
prints warnings and debug (i.e. expect match info)
eg. ./expect-lite -v r=host-008 c=pm_alternation.elt
If set, the following environment variables will be used:
This is just a brief synopsis of expect-lite commands to serve as a
reminder to those who already know expect-lite; other documentation
(such as the html document) must be consulted for fuller
> wait for a prompt, then send string to the remote host
>> send string to remote host, without waiting for prompt
< string/regex MUST be received from the remote host in the
alloted timeout or the script will FAIL!
<< literal string MUST be received (similar to '<' without regex
-< NOT expect, if string/regex IS received from the remote host the
script will FAIL!
# used to indicate comment lines, and have no effect
; are also used to indicate comment lines, but are printed to
stdout (for logging)
;; similar to above, but no extra newlines are printed (useful for
printing script help)
@num changes the expect timeout to num of seconds
$var= static variable assignment at script invocation
+$var= dynamic variable assignment
+$var increment value of $var by 1 decimal
-$var decrement value of $var by 1 decimal
=$var math functions, perform bitwise and arithmetic operations: <<
>> & | ^ * / % + - (see math functions)
! indicates an embedded expect line
? c-style if/then/else in the format ?cond?action::else_action
% label - used for jumping to labels
includes a expect-lite automation file, useful for creation of
common variable files, or 'subprograms/subroutines'
Include a fail script, which expect-lite runs only if the main
Set a user defined prompt (defined in regex)
*TERM Immediately terminates script, but returns 0 (pass)
*FAIL Immediately fails script, and returns 1 (fail)
Configuration directive which sets the shell imediately after
automatic login to remote host (see setting the shell)
A breakpoint which places user in interact mode, and pauses the
script and turns control of the keyboard over to the user
Multiple session support. Directs expect-lite to open a new
session and spawns a newshell
Debug information, displays all expect-lite variables. Can be
used in interact mode.
*EOLS LF|*EOLS CRLF
Controls end of line sequence sent to remote host, either line
feed, or carriage return + line feed.
Enable/disable informational messages
Enable/disable warning messages
Enable/disable debug messages
Disables color on stdout
Written by Craig Miller
Report bugs to <cvmiller at gmail dot com>.
Copyright (C) 2007-2010 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.
The full documentation for expect-lite is maintained as an HTML manual.
Please see http://expect-lite.sf.net/ for complete documentation.