D 2018-04-27T21:04:21.310 L Expect N text/x-markdown P 89158556fbc2e7a194a2323daf5991484f3db1ef U nils.carlson W 18511 ## Introduction Expect is a tool for automating interactive applications such as telnet, ftp, passwd, fsck, rlogin, tip, etc. Expect really makes this stuff trivial. Expect is also useful for testing these same applications. And by adding Tk, you can also wrap interactive applications in X11 GUIs. Expect can make easy all sorts of tasks that are prohibitively difficult with anything else. You will find that Expect is an absolutely invaluable tool - using it, you will be able to automate tasks that you've never even thought of before - and you'll be able to do this automation quickly and easily. ### Expect downloads, tickets and patches Downloading expect, creating tickets and posting patches is best done on the [sourceforge page](https://sourceforge.net/projects/expect/) . ### More information More information on Expect is available in the following documents: * Download [Expect for UNIX](#unix) or [Expect for Windows](#windows) now! * [*Exploring Expect*](#ee) is the book on Expect. * [Expect FAQ (Frequently Asked Questions List)](FAQ.html) * [Examples that come with Expect.](#examples) * [Contributed scripts in the public Expect archive](http://expect.nist.gov/scripts) * [The Expect README](README.distribution) is the same README file that comes with Expect. The README has lots of valuable information that has yet to be incorporated into this home page. It includes a description of the software distribution, where and how to send bug reports, how to get support or classes, and some other background information. * [History about the development of Expect and differences between versions](#history). The current version of Expect is 5.45.4, created Sun Feb 4 2018. * [Links to related information](#links) * * * ## Obtaining Expect for UNIX [//]: # (TODO: Update link) You can get Expect and the examples from its [File manager at SourceForge](https://sourceforge.net/projects/expect/files/). Then, at the command line, type: gunzip expect.tar.gz tar -xvf expect.tar This will create a directory containing the Expect distribution. Change to that directory and read the README file. Note: Expect requires Tcl. If you don't already have Tcl, you can download it as source from [the Tcl Core web site](http://core.tcl.tk/tcl/download) or as binaries from [ActiveState](http://www.activestate.com/activetcl). The most current snapshots of Expect will be found in the [expect](http://core.tcl.tk/expect) fossil repository. Not all snapshots are official releases. [//]: # (TODO: Update link) Not all old versions of Expect are available, but [some are](http://sourceforge.net/projects/expect/files). The current version is also available this way if you need to refer to it by explicit version. The sha-256 hash for [expect5.45.4.tar.gz](https://sourceforge.net/projects/expect/files/Expect/5.45.4/expect5.45.4.tar.gz/download) is: 49a7da83b0bdd9f46d04a04deec19c7767bb9a323e40c4781f89caf760b92c34 ## Obtaining Expect for Windows There is a windows port of Expect available from [ActiveState](http://activestate.com/). * * * ## Obtaining the examples The distribution contains many example scripts, including well-known scripts such as multixterm, kibitz, rftp (recursive ftp), passmass, autoexpect and the delicious beer script. All of the substantive examples in the book are included and many of them have man pages themselves. Here's the [list of examples](example/README). The best way to obtain the examples is to follow the directions for obtaining Expect (above). Once you have received and unpacked the distribution, you can find the examples in the example directory. You can also retrieve examples, man pages, and web pages [individually here](example) although you run the risk of trying an example that depends on a more up-to-date version of Expect than you have installed. (The web pages were all generated from the man pages so there should be no difference in content.) Here are man pages for some of the examples. (Not all of the examples need man pages but these do.) [//]: # (TODO: fix links) * [autoexpect](example/autoexpect.man.html) * [cryptdir/decryptdir](example/cryptdir.man.html) * [dislocate](example/dislocate.man.html) * [kibitz](example/kibitz.man.html) * [mkpasswd](example/mkpasswd.man.html) * [multixterm](example/multixterm.man.html) * [passmass](example/passmass.man.html) * [tknewsbiff](example/tknewsbiff.man.html) * [unbuffer](example/unbuffer.man.html) * [xkibitz](example/xkibitz.man.html) * * * ## [Links to related information]() The following are some other particularly worthwhile Expect-related links. * [Wikipedia](http://www.wikipedia.org/wiki/Expect) has a nice entry on Expect that some people find preferable to this page. [DejaGnu](http://www.gnu.org/software/dejagnu) is a popular Expect-based framework for testing other programs. If you are starting out and feel overwhelmed by the capabilities of Expect or would just like some guidance on how to structure a test suite, check out DejaGnu. DejaGnu is used by many standards testing organizations. [ expy](http://expectpy.sourceforge.net) is the Expect library embedded in Python instead of Tcl. [ActiveTcl](http://www.activestate.com/activetcl/) is an integrated collection of Tcl, Expect, and many other extensions. ### [More about Exploring Expect]() "Exploring Expect" is an excellent resource for learning and using Expect. (Pub: O'Reilly, ISBN 1-56592-090-2) The book contains hundreds of examples and also includes a tutorial on Tcl. Exploring Expect is 602 pages. ### Articles, Papers, and Chapters on Expect * Fisher, David L., [Advanced Programming in Expect: A Bulletproof Interface](http://www.cotse.com/dlf/man/expect/bulletproof1.htm), November, 1999. * Libes, D., "Expect", Tcl/Tk Extensions, ed, Mark Harrison, O'Reilly & Associates, Inc., 1997. * Libes, D., "Writing a Tcl Extension in Only ... 7 Years" ([HTML](doc/seven-years.html), [PDF](doc/seven-years.pdf)), [PostScript](doc/seven-years.ps), Proceedings of the Fifth Annual Tcl/Tk Workshop '97, Boston, MA, July 14-7, 1997. Winner of **Best Paper Award** at conference. * Libes, D., "[Tcl/Tk-based Agents for Mail and News Notification -- or -- A Tale of Two Biffs](http://www.nist.gov/msidlibrary/doc/libes97a.ps)", [Software - Practice & Experience](http://www.ep.cs.nott.ac.uk/wiley/journals/spe/speinfo.html), John Wiley & Sons, West Sussex, England, to appear. [This paper isn't really about Expect per se. However, a large section of the paper is on tknewsbiff which is one of the Expect examples.] * Friesenhahn, B., "Expect Offers UNIX Scripting", [Byte Magazine](http://www.byte.com/art/9704/sec5/art5.htm), April 1997. * Libes, D., [Automation and Testing of Interactive Character Graphic Programs](doc/chargraph.pdf), [Software - Practice and Experience](http://www.ep.cs.nott.ac.uk/wiley/journals/spe/speinfo.html), Vol. 27(2), p 123-137, February 1997. * Libes, D., "How to Avoid Learning Expect -- or -- Automating Automating Interactive Programs" ([PDF](doc/autoexpect.pdf), [PostScript](doc/autoexpect.ps)), Proceedings of the Tenth USENIX System Administration Conference (LISA X), Chicago, IL, September 30 - October 4, 1996. * Libes, D., "Writing CGI Scripts in Tcl" ([PDF](doc/cgi.pdf), [PostScript](doc/cgi.ps)), Proceedings of the Fourth Annual Tcl/Tk Workshop '96, Monterey, CA, July 10-13, 1996. [This paper isn't really about Expect per se. However, it does show a nice example of Expect in a CGI script for the purpose of changing passwords through web pages. The complete form/script can be found in the source distribution.] Winner of **Best Presentation Award** at conference. * Libes, D., [Terminal Emulation for Automation and Testing of Character Graphic Programs: A Code Walkthrough](http://www.nist.gov/msidlibrary/doc/libes96a.ps), Proceedings of The 21st Annual Trenton Computer Festival (TCF '96), Trenton, NJ, April 21-22, 1996 - a much longer and more detailed version of the SP&E paper (above) [I submitted this originally to SP&E and they cut it down to what ultimately appeared but recommended that this version was still worth publishing elsewhere - hence this second publication.] * Faught, D., Testing Interactive Programs, Software QA Magazine, Vol. 3, No. 1, February 1996. * Fischer, P., The Expect Program and Other Skunkware Tools, SCO World, February, 1996. * Libes, D., Handling Passwords with Security and Reliability in Background Processes ([PostScript](doc/bgpasswd.ps), [PDF](doc/bgpasswd.pdf)), Proceedings of the 1994 USENIX LISA VIII Conference, San Diego, CA, September 19-23, 1994 - Simple techniques to allow secure handling of passwords in background processes. * Morse, W., A Tcl/Tk and Expect Tutorial, World Wide Technology Conference, Houston, TX, December 1, 1994. Winner of **Best Paper Award** at conference. * Libes, D., Ouch, Those Programs Are Painful, ORA.COM, O'Reilly & Associates, Inc., Fall '94. * Libes, D., [A Debugger for Tcl Applications](doc/tcl-debug.ps), Proceedings of the 1993 Tcl/Tk Workshop, Berkeley, CA, June 10-11, 1993 - A presentation of the Tcl debugger - theory, implementation, and use. **Warning**: The examples in all of the papers listed below here are archaic. Critical aspects (usually syntax) of both Expect and Tcl have changed since they were written. (It's not that Expect has changed that recently - rather it's because of incredibly slow turnaround by many reviewers, editors, and journals.) The papers still make interesting reading - just don't study the examples too closely! Fortunately, most of the examples from the papers also accompany the Expect distribution - and all of the online examples are up to date. * McNutt, D., Expect, January, 1994, UNIX Review, Vol. 12, No. 6, January 1994 - Introductory article. * Libes, D., [X Wrappers for Non-Graphic Interactive Programs](doc/expectk.ps), Proceedings of Xhibition '94, San Jose, CA, June 20-24, 1994 - Discussion of wrapping interactive programs with Tk. * Dichter, C., Surviving Software Testing, UNIX Review, pps 29-36, V11, #2, Feb 1993. * Libes, D., [Kibitz - Connecting Multiple Interactive Programs Together](doc/kibitz.ps), Software - Practice & Experience, Vol. 23, No. 5, May 1993 - Paper on connecting multiple interactive programs together using Expect. * Libes, D., [Obfuscated C and Other Mysteries, Chapter 36 ("Expect")](http://www.wiley.com), John Wiley & Sons, ISBN 0-471-57805-3, January 1993 - An explanation of some of the more interesting source code to an early version of Expect. * Libes, D., Automating Interactive Applications in the Network Environment, International Communications Association Journal, May 17, 1992. * Smith, B., Software Corner, Byte Magazine, 1992. * Caffrey, P., User Interfaces and Automating Computer HumaN Interaction, MSc. Thesis, Amdahl Ireland Ltd., 1992. * Woodson, B., Regression Testing Using Expect, How To Implement Quality In Software Conference, Santa Clara Valley Software Quality Association, June 29, 1991. * Libes, D., [Regression Testing and Conformance Testing Interactive Programs](doc/regress.ps), Proceedings of the Summer 1992 USENIX Conference, San Antonio, TX, June 8-12, 1992 - Discussion of regression and conformance testing. If you are interested in this, you should also check out [DejaGnu](http://www.gnu.org/software/dejagnu.html). * Libes, D., [Expect:Scripts for Controlling Interactive Programs](doc/scripts.ps), Computing Systems, Vol. 4, No. 2, University of California Press Journals, 1991 - A nice overview with a balance of example scripts and explanations. * Libes, D., Implementor's Notebook: Implementing a Trap Command, C Users Journal, Vol. 9, No. 3, R&D Publications, Lawrence, KS, January, March, 1991 - Explanation of how Expect's trap command was implemented. * Libes, D., Implementor's Notebook: Expect, C Users Journal, Vol. 9, No. 1, R&D Publications, Lawrence, KS, January, January, 1991 - Explanation of some of the more interesting source code to an early version of Expect (an improved version of this appeared later as Obfuscated C and Other Mysteries, Chapter 36 ("Expect"). * Anderson, D., "Expect", January, 1991, SunExpert Magazine, Vol. 2, No. 1, January 1991 - Introductory article. * Libes, D., [Using Expect to Automate System Administration Tasks](doc/sysadm.ps), Proceedings of the 1990 USENIX Large Systems Administration Conference (LISA) IV, Colorado Springs, CO, October 17-19, 1990 - Examples and discussion, specifically aimed at system administrators. * Libes, D., [Expect:Curing Those Uncontrollable Fits of Interaction](doc/seminal.ps), Proceedings of the Summer 1990 USENIX Conference, Anaheim, CA, June 11-15, 1990 - Discussion of Expect's implementation, philosophy, and some performance notes. * * * ## [History]() Expect was conceived of in September, 1987. The bulk of version 2 was designed and written between January and April, 1990. Minor evolution occurred after that until Tcl 6.0 was released. At that time (October, 1991) approximately half of Expect was rewritten for version 3. See the [HISTORY file](HISTORY) for more information. The HISTORY file is included with the Expect distribution. Around January 1993, an alpha version of Expect 4 was introduced. This included Tk support as well as a large number of enhancements. A few changes were made to the user interface itself, which is why the major version number was changed. A production version of Expect 4 was released in August 1993. In October 1993, an alpha version of Expect 5 was released to match Tcl 7.0. A large number of enhancements were made, including some changes to the user interface itself, which is why the major version number was changed (again). The production version of Expect 5 was released in March '94. In the summer of 1999, substantial rewriting of Expect was done in order to support Tcl 8.2. (Expect was never ported to 8.1 as it contained fundamental deficiencies.) This included the creation of an exp-channel driver and object support in order to take advantage of the new regexp engine and UTF/Unicode. The user interface is highly but not entirely backward compatible. See the NEWS file in the distribution for more detail. There are important differences between Expect 3, 4, and 5. See the CHANGES.* files in the distribution if you want to read about the differences. Expect 5.30 and earlier versions have ceased development and are not supported. However, the old code is available from http://expect.nist.gov/old. The Expect book became available in January '95. It describes Expect 5 as it is today, rather than how Expect 5 was when it was originally released. Thus, if you have not upgraded Expect since before getting the book, you should upgrade now. ### Historical notes on Tcl and Tk according to John Ousterhout I got the idea for Tcl while on sabbatical leave at DEC's Western Research Laboratory in the fall of 1987. I started actually implementing it when I got back to Berkeley in the spring of 1988; by summer of that year it was in use in some internal applications of ours, but there was no Tk. The first external releases of Tcl were in 1989, I believe. I started implementing Tk in 1989, and the first release of Tk was in 1991. * * * ## Even more links ### Books * Tcl and the Tk Toolkit by John Ousterhout, Addison-Wesley, 1994, ISBN 0-201-63337-X - the seminal book on Tcl and Tk. [Practical Programming with Tcl and Tk](http://www.beedub.com/book/) by Brent Welch, Prentice Hall, 1995, ISBN 0-13-182007-9. [Graphical Applications with Tcl and Tk](http://ourworld.compuserve.com:80/homepages/efjohnson/tclbook.htm) by Eric F. Johnson, M&T Books, 1996, ISBN 1-55851-471-6 - Covers cross-platform development with Tcl and Tk on Windows and UNIX. There are too many books to list all of them here. See the Tcl FAQ for a bigger list. ### FAQs * [Expect FAQ](FAQ.html) [Tcl FAQ Part 1: General questions](http://www.purl.org/net/tcl-faq/part1.html) [Tcl FAQ Part 2: Bibliography, maillists, etc.](http://www.purl.org/net/tcl-faq/part2.html) [Tcl FAQ Part 3: Misc questions](http://www.purl.org/net/tcl-faq/part3.html) [Tcl FAQ Part 4: Applications](http://www.purl.org/net/tcl-faq/part4.html) [Tcl FAQ Part 5: Extensions](http://www.purl.org/net/tcl-faq/part5.html) [Tcl Windows FAQ](http://www.pconline.com/~erc/tclwin.htm) ### Miscellaneous Pages that are particularly worthwhile but don't fall in the preceding categories. * [Tcler's Wiki](http://wiki.tcl.tk) - Collaborative web pages on Tcl * [Mark Roseman's offer](http://www.projectforum.com/pf/tclhosting.html) to host Project Forum sites for use by open source Tcl/Tk projects * [A Wiki-like site devoted to improving Tk](http://tcl.projectforum.com/tk/) so it can be used to build commercial-class GUIs * Newsgroups * * [comp.lang.tcl](news:comp.lang.tcl) - Expect discussion/questions are encouraged in this newsgroup. * [comp.lang.tcl.announce](news:comp.lang.tcl.announce) * [Community's Tcl page, hosted by ActiveState](http://www.tcl.tk) * * * ###### Last edited: Mon Aug 3 12:43:13 EDT 2009 Technical Contact: [Don Libes](http://www.nist.gov/msidstaff/libes) [The National Institute of Standards and Technology (NIST)](http://www.nist.gov) is an agency of the [U.S. Department of Commerce](http://www.doc.gov/). [Privacy policy / security notice / accessibility statement](http://www.nist.gov/public_affairs/privacy.htm) / [Disclaimer](http://www.nist.gov/public_affairs/disclaim.htm) / [Freedom of Information Act (FOIA)](http://www.nist.gov/admin/foia/foia.htm) / [No Fear Act Data](http://www.nist.gov/director/civil/nofearpolicy.htm) / [ExpectMore.gov (performance of federal programs)](http://www.nist.gov/cgi-bin/exit_nist.cgi?url=http://www.ExpectMore.gov) / [NIST Information Quality Standards](http://www.nist.gov/director/quality_standards.htm) [Disclaimer/Privacy](http://www.nist.gov/public_affairs/disclaim.htm) Z 5a042ebb1594495adcc17c69e9035ad5