Obtaining Expect and the Examples

Expect may already be installed on your system, typically in /usr/local/bin. If you cannot find Expect, ask your system administrator. If you do not have a system administrator, you can obtain Expect by following the instructions below. Expect requires no special permissions to install, nor does it have to be installed in any particular place. You can even try it out in your own directory.

Expect includes a number of examples, several of which are useful as tools in their own right. Indeed, quite a few have man pages of their own and can be installed along with Expect. If the examples are not installed, you can find them in the example directory of the Expect distribution. Ask your local system administrator where the distribution is.

The examples provided with Expect are subject to change, but below is a list of just a few of the examples. The README file in the example directory contains a complete list as well as full explanations about each of the examples:

Example 1-1. 

chess.exp

play one chess game against another

dislocate

allow disconnection from and reconnection to background processes

dvorak

emulate a Dvorak keyboard

ftp-rfc

retrieve an RFC from the Internet via anonymous ftp

kibitz

let several people control a program at the same time for remote assistance, group editing, etc.

lpunlock

unhang a printer waiting for a lock

mkpasswd

generate a good random password and optionally run passwd with it

passmass

set a password on many machines simultaneously

rftp

allow recursive get, put, and list from ftp

rlogin-cwd

rlogin with the same current working directory

rogue.exp

find a good game of rogue

timed-read

limit the amount of time a read from the shell can take

timed-run

limit the amount of time for which a program can run

tkpasswd

change passwords in a GUI

tknewsbiff

pop up a window (or play sounds, etc.) when news arrives in selected newsgroups

tkterm

emulate a terminal in a Tk text widget

unbuffer

disable output buffering that normally occurs when program output is redirected

weather

retrieve a weather forecast from the Internet

These and additional examples are available with the Expect distribution. The README file in the distribution also describes the location of the Expect archive which holds even more scripts. You can also contribute your own scripts to the archive. Particularly large or sophisticated applications (such as those which combine Expect with other extensions) can be found separately in the Tcl archive (see page 19).

There is a high probability that you already have Expect on your system. Expect is shipped by many vendors with their operating system utilities. Expect can also be found on many software distributions including GCT from Testing Foundations, USENET Software from UUNET, the Sun User Group CD-ROM, the Prime Time Freeware CD-ROM, the Lemis CD-ROM, and others. Even if you do not have one of these, some other user on your system may have already retrieved Expect from an Internet repository.

The entire Expect distribution can be obtained from many sites around the Internet. Your best bet to finding a nearby site is to use an Archie server. Archie maintains a database of thousands of computers across the Internet and what programs they are willing to supply. If you do not know how to use Archie, you can obtain instructions by sending email to archie@archie.sura.net with the word help as the contents of the message.[6]

As this book is being written, Archie reports at least one site in the following countries where Expect can be obtained:

Country

Internet site

Australia

minnie.cs.adfa.oz.au

Austria

ftp.tu-graz.ac.at

Canada

julian.uwo.ca

England

unix.hensa.ac.uk

France

ftp.imag.fr

Germany

ftp.informatik.tu-muenchen.de

Greece

pythia.csi.forth.gr

Ireland

walton.maths.tcd.ie

Israel

cs.huji.ac.il

Japan

akiu.gw.tohoku.ac.jp

Netherlands

svin02.info.win.tue.nl

Norway

ftp.eunet.no

Sweden

ftp.sunet.se

Switzerland

ftp.switch.ch

United States

ftp.cme.nist.gov

Currently, the site ftp.cme.nist.gov always contains the latest version of Expect (or a pointer to it). To retrieve it from there, you can use anonymous ftp or request automatic email delivery.

To get Expect from ftp.cme.nist.gov via ftp, retrieve the file pub/expect/README. This will tell you what other files you need to retrieve and what to do after that. Typically, you need a copy of Expect and a copy of Tcl. You may also want to get a copy of Tk. These can be found in the same directory as Expect.

If you are not directly on the Internet but can send mail, you can request email delivery of the files. Send a message to "library@cme.nist.gov“. The message body should be:

send pub/expect/README

The site ftp.cs.berkeley.edu always contains the latest releases of Tcl and Tk. This site permits anonymous ftp. If you would like to request email from that site, any of the other sites listed above, or any other anonymous ftp sites, you can use an "ftp by mail” agent, such as the one provided by Digital Equipment’s Western Research Laboratories. Complete instructions for using ftp-mail may be retrieved by emailing to . The subject should be "ftpmail" and the message body should be "help“.



[6] All hostnames and filenames in this chapter are subject to change.

Get Exploring Expect now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.