Exploring Expect

A Tcl-based Toolkit for Automating Interactive Programs

By Don Libes
December 1994
Pages: 602
ISBN 10: 1-56592-090-2 | ISBN 13: 9781565920903
starstarstarstarstar (3) (Average of 4 Customer Reviews)

Buy 2 Get 1 Free Free ShippingGuarantee

Book description

Written by the author of Expect, this is the first book to explain how this part of the UNIX toolbox can be used to automate Telnet, FTP, passwd, rlogin, and hundreds of other interactive applications. Based on Tcl (Tool Command Language), Expect lets you automate interactive applications that have previously been extremely difficult to handle with any scripting language.
Full Description

Expect is quickly becoming a part of every UNIX user's toolbox. It allows you to automate Telnet, FTP, passwd, rlogin, and hundreds of other applications that normally require human interaction. Using Expect to automate these applications will allow you to speed up tasks and, in many cases, solve new problems that you never would have even considered before. For example, you can use Expect to test interactive programs with no changes to their interfaces. Or wrap interactive programs with Motif-like front-ends to control applications by buttons, scrollbars, and other graphic elements with no recompilation of the original programs. You don't even need the source code! Expect works with remote applications, too. Use it to tie together Internet applications including Telnet, Archie, FTP, Gopher, and Mosaic. Don Libes is the creator of Expect as well as the author of this book. In Exploring Expect, he provides a comprehensive tutorial on all of Expect's features, allowing you to put it immediately to work on your problems. In a down-to-earth and humorous style, he provides numerous examples of challenging real-world applications and how they can be automated using Expect to save you time and money. Expect is the first of a new breed of programs based on Tcl, the Tool Command Language that is rocking the computer science community. This book provides an introduction to Tcl and describes how Expect applies Tcl's power to the new field of interaction automation. Whether your interest is in Expect or interaction automation or you simply want to learn about Tcl and see how it has been used in real software, you will find Exploring Expect a treasure trove of easy-to-understand and valuable information.
Post-purchase benefits:

Register your book | Submit Errata | Expect home page


Browse within this book

| Table of Contents | Sample Chapter | Colophon

Book details

First Edition: December 1994
ISBN: 1-56592-090-2
Pages: 602
Average Customer Reviews: starstarstarstarstar (3) (Based on 4 Reviews)


Featured customer reviews

Write a Review


Good book, but too little too late for me,  August 25 2006
Rating: StarStarStarStarStar
Submitted by Anonymous Reader   [Respond | View]

I purchased this book because it is the *only* good reference for expect. One cannot understand and write this language successfully without this book. However, it took over four months to recieve the book after paying for it, and I found that the book itself was almost ten years old! Some of the code is now out of date, links are broken, and there is n way to download the code from the book. What I needed, several months ago, was an up-to-date solution from this book on the night that I ordered it. Any programming language that will survive will provide a way to get that information. Expect is clearly stagnant.


Great Reference!,  August 13 2005
Rating: StarStarStarStarStar
Submitted by Russell Chapman   [Respond | View]

Written by the author of the program, this book is exactly what I expected, and more.

If you enjoy automating tasks and writing scripts, Expect is a great addition to your toolbox, and this book is a great companion and welcome addition to your reference shelf.

In performing many UNIX administration tasks, one which my current job allowed me the opportunity to automate is a means of maintaining passwords on many servers. In particular, we have a requirement to change root's password on some 1600+ servers monthly, as well as our own passwords on hundreds of servers. We have every flavor of UNIX and more variations of what to expect interacting with ssh, telnet, Sun, HP, Linux, AIX, NCR, and as many differences among the system prompts. After buying this book, I found much of my learning curve easier. The examples and the overview of Tcl are priceless.

The Expect man pages are good, but having this book handy, with the program author's colorful and descriptive explanations has been a great help in the above and other successful tools using Expect.

This may seem as much a rave of Expect as well as this book, but as a fan of both and a person who prefers a good reference manual, Exploring Expect earns my recommendation.



not for beginners,  August 08 2005
Rating: StarStarStarStarStar
Submitted by tjotjobina   [Respond | View]

I have tried using this book to learn expect and are failed. Have given up learning expect since it seems there is no other book about expect. like a gentle introduction to expect. if u are a beginner dont bother with this

Read all reviews


Exploring Expect Review,  October 11 2000
Rating: StarStarStarStarStar
Submitted by Michael Chelomanov   [Respond | View]

I much appreciate the author's efforts in writing such a wonderfull program but speaking about the book... I found it to be a bit hard to follow. The systemization in introducing this technology leaves much to be desired.

Most of the O'Reilly books you can literally can start reading and actually using them without of any prior experience in whatever the subject is, unfortunately it does not apply to the Exploring Expect book.

For example right now I need to find out how to programm cursor movemets via expect in order to navigate menu driven telnet interface, and quess what - the only mentioning of the arrows is on page 286, which asks me to write code, which will do it. SO I an surfing the WWW for the answer. I would think that would be quite common question, but for some reason it is not answered in the book.

Having said all above it is still a-must-to-have for any unix sysadmin it's O'Reilly book after all.


Media reviews

"As with all good languages, as far back as FORTRANIV and SNOBOL, Expect's justified popularity is partly driven by a first-rate book, in this case Don Libes' Exploring Expect." --Jeffrey Copeland and Jeffrey Haemer, Server/Workstation Expert, June 2001

"Expect was the first widely used Tcl application, and it is still one of the most popular. This is a must-know tool for system administrators and many others." --John Ousterhout, John.Ousterhout@Eng.Sun.COM

"Expect is an absolutely wonderful, marvelous program. It is one of the most useful tools I've seen in 15+ years of UNIX hacking. Expect is going to save us several thousand dollars in licensing fees in the next year alone, some inestimable number of programming hours, and allow us to provide our users much better service than we otherwise could have." --John W. Pierce, Department of Chemistry and Biochemistry, University of California, San Diego

"Expect is a lifesaver for a project that I am currently involved with. I have only been working with Expect for the last couple of days, but it has already shaved about 6 months off of the completion time of the project." -- Ron Young, System Computing Services, University of Nevada

"Expect has become a necessary tool for system administration. In a short time, we have applied Expect in a number of areas and have dramatically reduced the man hours required for common, repetitive tasks." --Thomas Naughton, Hull Trading Company

"I'd been using expect for automating various grubby day-to-day system tasks for a long time. During the procurement for EPA's supercomputer, we found that we needed a portable way to quantify interactive response time for the benchmark. Using the 'expect' package we were able to 'drive' the standard vi editor to produce an average of seconds/command keystroke." --Frank Terhaar-Yonkers, Martin Marietta Technical Services/U.S. EPA

"Thanks for Expect. It just made an impossible project possible." --Bruce Barnett, GE Corporate Research and Development Center

"My Expect scripts function perfectly. The original problem defeated several people here (including those much more expert in Unix than myself), so it is a relief to have found such a simple solution." --Richard Gartner, Bodleian Library, Oxford University, United Kingdom

"Expect is great. I've written an Expect script that is: 1) easy, 2) more reliable than a previously cobbled together system using 'perl -> mail -> perl -> kermit. The whole thing is now one small Expect script." --Rob Urban, Migration Consultant, Digital Equipment GmbH, Munich, Germany

"It is a mystery to me how UNIX could have existed for years without Expect." --Erik Basilier, Motorola

"I'm really impressed with how functional my software has become because of Expect. Thanks for a wonderful program!!!!!!" --John Conti, Cisco Systems

"Thanks to Expect, we've solved many problems that would have otherwise needed a lot of programming - meaning we would not have had time to do them!" --Pekka Kytolaakso, Centre for Scientific Computing, Espoo, Finland

"I'm changing passwords on over 600 hosts, and BOY! am I glad that Expect's passmass script exists! Now *there's* an indispensible tool!" -- Win Bent, University Comp. Services, University of Southern California

"Thanks for making my life easier. This program has really helped me shorten the cycle time for Software Q.A. Expect is like a dream come true for automation. My productivitity has really increased." -- Brian F. Woodson, 3Com NSD Software QA.

"What I really like about Expect is that it lets you shift in and out of interactive and automated mode as you are driving programs." -- Lloyd Zusman, Master Byte Software, Inc.

"I can recall my reaction when I fist saw an announcement for Don Libes' Exploring Expect:`550+ pages about expect? You've got to be kidding!' It's now a couple of months later, I've read all of those pages, and I'm no longer so incredulous. There's more to expect -- or, more accurately, to its application domain -- than I had realized.

"Expect was designed to automate and control interactive programs, which are often very perverse. Libes explains expect and those applications side by side, demonstrating techniques for handling strange situations through a carefully planned series of examples. Along the way, the reader comes to understand the reasons behind some of expect's features, and gains a feel for the many (often surprising) ways that expect can be put to use.

"In addition, there's more here than just expect proper. Expect is a Tcl application, and effective use of expect requires a knowledge of Tcl. So a nice Tcl overview is included. Expect comes with a Tcl debugger, which is explained. There are sections on using expect with Tk (to provide X interfaces to character-based applications), using expect from C or C++ instead of Tcl, and using expect with other Tcl extensions.

"It's clear that a lot of work went into this book. The examples are real, useful programs, not contrived exercises, and they are presented and explained well. Furthermore, I got the impression that Libes kept track of questions users asked him, and drew on them to make sure that the book covers all of the tricky areas. Exercises at the end of each chapter are thought-provoking and serve to emphasize the points of the chapter. And the index is very thorough. That, plus two mini-indexes, one to expect commands, options, and variables, and the other to examples, make this tutorial-style book a passable reference. I would have liked it if the manual page had been included, but it isn't a glaring omission.

"All in all, Exploring Expect is a fine book about a fine and veratile tool." --Glenn Vanderburg, ;login:, April 1995

"This book is as dog-eared as my Perl 4 camel book. O'Reilly claims a desire to solve the world's pain, for this they can offer no better evidence than the monkey book this book covers many of the issues involved in making computers act like humans. With wit and care, Don explicates examples both small and large that cover many of the issues that come in these situations. I have not found equivalent depth of knowledge anywhere else...Read the book if you do system integration. Enjoy the book if you like to stretch your (recent) linux or BSD box using the utilities you use daily. --Derek Lane, Raleigh Perl Mongers, August 2000

Hide extended reviews


See larger cover