Version 160 of Expect

Updated 2010-03-17 13:03:56 by LVwikignome

Expect is known primarily as an indispensable application for system administrators. Amazingly enough, it is, at its heart, Just Another Tcl Extension (JATE).

People use Expect to automate interaction with non-GUI (and typically non-cursor-controlled, even though a persevering Expect programmer can tackle them, too) applications that prompt the user for input.

Examples of commands that often appear in Expect scripts are the Unix passwd, ftp, telnet, ssh, sudo, and command-line shells. Expect is the natural answer for those who want to automate password changes, periodically update FTP sites, manage Cisco routers, or check the statuses of a collection of remote systems by logging in.

What: Expect
Where: http://expect.sf.net/ 
       http://expect.nist.gov/ 
       http://expect.nist.gov/FAQ.html 
       http://expect.nist.gov/scripts/ 
       ftp://ftp.nist.gov/mel/div826/subject/expect/ 
       http://prdownloads.sf.net/expect/slavedrv1.1.zip 
       http://phaseit.net/claird/comp.lang.tcl/expect.html 
Description: Expect is a scripting language to interace with programs
        such as FTP, telnet, fsck, and others that normally cannot be
        automated from a shell script. Think of it as providing the means
        to 'remote control' other programs. It is thus also good for
        automating program exection on remote systems, and providing the
        means to creating Tk interfaces on top of other, non-GUI, programs
        V5.x is Tcl 7.x compatible. 
        The version on liv, while not from the author, is a set of source 
        modified to be used with tclX, BLT, and TkSteal (unmaintained). 
        V5.28 (the tar.gz version) is Tcl 8.0 compatible. 
        This package will also build expectk, which allows one 
        to write Tk interfaces to the above types of programs.
        The version at berkeley is a release of Expect for Windows NT,
        which includes patches to Tcl to allow fileevent to work 
        for pipes and serial ports. It does not work for Windows 95. 
        Check its web page for info on the latest development snapshots.
        The url for a version of Expect 5.25/Tcl 7.6 for Japanese Tcl 
        is mentioned above.
        The slavedrv code mentioned above is an attempt to port 
        a recent version of expect to recent version of Windows. 
        It may not have all the expect functionality.
        Version 5.44.1 of Expect, compatible with Tcl 8.5, 
        is also available from the SF.net CVS repository.
Updated: 8/2009
Contact: See the web sites 

External Resources

http://expect.nist.gov/ was the original home Web site for Expect. It supplies sources and considerable history, background, and instruction. It does fail to mention, though, recognition [L1 ] of Expect as one of the 100 most important publications of NIST's [L2 ] first century. Note that the warning regarding expect 5.44 on that page is seriously out of date. The CVS 5.44 version linked to below is fine (and needed to build against Tcl 8.5).

The current maintenance of the package can be found at http://expect.sf.net/ , with access to the CVS available via sf.net's cvs repository. Note that the link (on the sf.net primary page) for the CVS repository is out of date; visit http://sf.net/projects/expect/ and use the link there to look at the cvs repository from your web browser.

This package is part of the ActiveTcl Batteries Included distribution on unix and as of 2005, the Windows version is available via ActiveTcl as well [L3 ].

ActiveState maintains online copies of documentation at [L4 ].

There's an expect FAQ here: http://expect.nist.gov/FAQ.html .

There's a book called BOOK Exploring Expect to which most people refer when asked questions about Expect.

CL keeps a bit of supplementary information on Expect at [L5 ].

Expect External Resources gives pointers to some wiki-external Expect material.

escargo 11 Sep 2007 - I found an expect-lite project on SourceForge: http://expect-lite.sourceforge.net/

LV 2007 Nov 09

expect4j [L6 ] provides a certain level of expect's functionality to the Jacl / Java programmer. Package author Justin Ryan reports on the TclJava mailing list [L7 ] I've successfully ported a 100K tcl script based on expect to tcljava, without any changes, by just using expect4j.


Wiki-Local Resources


Articles

  1. Don explains how far from trivial pty management is, and other lessons, in his memoir [L8 ] on Expect's first seven years.
  2. "Expect Success" [L9 ] is, for Kim Richert, "the best Expect article I've read".
  3. "Expect--the only language you need" [L10 ]
  4. "Expect: The Firefighter's Friend" [L11 ]
  5. "Unknown Expect" [L12 ]
  6. "Test-driven development, Expect, and Systems Administration" [L13 ]
  7. http://www.csc.calpoly.edu/~dbutler/tutorials/winter96/expect/tutorial.html
  8. "Using Expect to Configure Cisco Routers" [L14 ]: "... the entire task would take about a month for two people ... What used to take us a month now takes about an hour to finish completely and accurately."
  9. "Expect plays a crucial role in network management" [L15 ]

Example Scripts


LV Note that expect is also a command that is a part of the expect extension; see the expect source distribution for the doc.

Lars H: Also note that in the latter sense, expect is a powerful control structure (pretty much an automaton, is it not?).


srinadh - 2009-10-08 10:41:28

I have an expect program. Sometimes it produces a core dump. How do I see core dump backtrace? Thanks