LV: Our local public library used to have a telnet interface to its patron account system. I wrote an Expect script which logged onto the system, queried for the holdings status of each account in my family, then logged off. I would run this from cron and get a report as to which books were coming up for return, what items were held for pick up, and so on. I then placed the text version of that report into a directory where a daily sync to my Palm Pilot would result in a PalmOS memo containing this info.
Expect is a scripting language to interface 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 execution 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.
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.
The current Expect code was written to pre-7.5 standards, so until someone steps forward to modernize the code base, should be treated gently. It is not multi-interp-safe, to say nothing about threads.
The current maintenance of the package can be found at expect.sf.net , with access to the CVS available via sf.net's cvs repository.
Expect is part of the ActiveTcl Batteries Included distribution on Unix and as of 2005, the Windows version is available via ActiveTcl as well [L1 ].
slavedrv1.1 was a nascent attempt to port expect to recent versions of Windows, and is no longer available.
supplies sources and considerable history, background, and instruction. It does fail to mention, though, recognition of Expect as one of the 100 most important publications of NIST's 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 postscript file seems to be collated in reverse order. Anyone who sees this note and has the power to fix it, please do! The following command will reverse the pages in a postcript file. AMucha 2020-12-11
AMG: Here's some history about Expect and Tcl in general: [L2 ]. Also see [L3 ] for more Unix tools. Here's a quote from the latter page:
Expect - a unique Unix tool (that is now available for Windows too). BTW one of the earlier names for Expect was "sex" as it related to "intercourse" of programs ;-). I strongly recommend to learn how to use it. See TCL, TK & Expect for more information .
provides a certain level of expect's functionality to the Jacl / Java programmer. Package author Justin Ryan reports on the TclJavamailing list : I've successfully ported a 100K tcl script based on expect to tcljava, without any changes, by just using expect4j.
susja 2010-11-12 14:05:18: I have a simple task: run autoexpect program to automate telnet. I was able to do it on my Solaris box but I am stuck on my Windows XP box. Here's what I did:
downloaded expect-5.43.tar to my local drive, untar it and have Expect located at C:\.... . I tried to execute 'autoexpect' but it says: "'autoexpect' is not recognized as an internal or external command"
I installed ActiveTcl 8.5.9. Successfully ran 'teacup install Expect'.
Here I'm blocked: how now I could execute autoexpect program?
thanks in advance
bodangly 2011-12-13 18:47:18: The above question is old and the user likely found the answer however for reference, the PATH environment variable needs to have the location of the autoexpect program appended to it.