Expect (version 2.8) - a program to control interactive programs

Don Libes libes at cme.nist.gov
Mon Jul 2 15:02:33 AEST 1990


"Expect" is a program that performs programmed dialogue with other
interactive programs.  Here is a brief extract from the man page:

     expect is a program that "talks" to other  interactive  pro-
     grams  according  to a script.  Following the script, expect
     knows what can be expected  from  a  program  and  what  the
     correct  response  should  be.  An interpreted language pro-
     vides branching and high-level control structures to  direct
     the  dialogue.   In  addition, the user can take control and
     interact directly when desired, afterward returning  control
     to the script.

     The  name  "expect"  comes  from  the  idea  of  send/expect
     sequences  popularized  by uucp, kermit and other modem con-
     trol programs.  However unlike uucp, expect  is  generalized
     so  that it can be run as a user-level command with any pro-
     gram and task in mind.  (expect can actually talk to several
     programs at the same time.)

     For example, here are some things expect can do:

          o   Cause your computer to dial you back, so  that  you
              can login without paying for the call.

          o   Start a game (e.g., rogue) and if the optimal  con-
              figuration  doesn't  appear,  restart it (again and
              again) until it does, then  hand  over  control  to
              you.

          o   Run fsck, and in response to its questions,  answer
              "yes",  "no"  or give control back to you, based on
              predetermined criteria.

          o   Connect to another network or BBS (e.g., MCI  Mail,
              CompuServe) and automatically retrieve your mail so
              that it appears as if it  was  originally  sent  to
              your local system.

     There are a variety of reasons why the shell cannot  perform
     these  tasks.   (Try,  you'll  see.)  All  are possible with
     expect.

     In general, expect is useful for running any  program  which
     requires  interaction between the program and the user.  All
     that is necessary is that the interaction can be  character-
     ized  programmatically.   expect can also give the user back
     control (without halting the program  being  controlled)  if
     desired.   Similarly,  the  user  can  return control to the
     send/expect script at any time.

More examples and further discussion about implementation, philosophy,
and design are in "expect: Curing Those Uncontrollable Fits of
Interaction" by Don Libes, Proceedings of the Summer 1990 USENIX
Conference, Anaheim, California, June 11-15, 1990.

expect may be ftp'd as pub/expect.shar.Z from durer.cme.nist.gov.  If
you cannot ftp, you may request email copies by mailing to "library@
cme.nist.gov".  The contents of the message should be (no subject
line) "send pub/expect.shar.Z".  Once you have retrieved the system,
please read the INSTALL file.  The paper mentioned above can be ftp'd
separately as pub/expect.ps.Z.

Don Libes          libes at cme.nist.gov      ...!uunet!cme-durer!libes



More information about the Comp.sys.sun mailing list