Welcome to Linux Knowledge Base and Tutorial
"The place where you learn linux"

 Create an AccountHome | Submit News | Your Account  

Tutorial Menu
Linux Tutorial Home
Table of Contents

· Introduction to Operating Systems
· Linux Basics
· Working with the System
· Shells and Utilities
· Editing Files
· Basic Administration
· The Operating System
· The X Windowing System
· The Computer Itself
· Networking
· System Monitoring
· Solving Problems
· Security
· Installing and Upgrading
· Linux and Windows

Man Pages
Linux Topics
Test Your Knowledge

Site Menu
Site Map
Copyright Info
Terms of Use
Privacy Info
Masthead / Impressum
Your Account

Private Messages

News Archive
Submit News
User Articles
Web Links


The Web

Who's Online
There are currently, 68 guest(s) and 0 member(s) that are online.

You are an Anonymous user. You can register for free by clicking here




       autoexpect [ args ] [ program args...  ]


       autoexpect watches you interacting  with  another  program
       and creates an Expect script that reproduces your interac­
       tions.  For straightline scripts,  autoexpect  saves  sub­
       stantial  time  over writing scripts by hand.  Even if you
       are an Expect expert, you will find it convenient  to  use
       autoexpect to automate the more mindless parts of interac­
       tions.  It is much easier to cut/paste hunks of autoexpect
       scripts  together than to write them from scratch.  And if
       you are a beginner, you may  be  able  to  get  away  with
       learning  nothing more about Expect than how to call auto­

       The simplest way to use autoexpect is to call it from  the
       command line with no arguments.  For example:

            % autoexpect

       By  default,  autoexpect  spawns a shell for you.  Given a
       program name and arguments, autoexpect  spawns  that  pro­
       gram.  For example:

            % autoexpect ftp ftp.cme.nist.gov

       Once  your  spawned program is running, interact normally.
       When you have exited the shell (or program that you speci­
       fied),  autoexpect  will  create a new script for you.  By
       default, autoexpect writes the new script to "script.exp".
       You  can  override this with the -f flag followed by a new
       script name.

       The following  example  runs  "ftp  ftp.cme.nist.gov"  and
       stores the resulting Expect script in the file "nist".

            % autoexpect -f nist ftp ftp.cme.nist.gov

       It  is  important  to  understand that autoexpect does not
       guarantee a working script because it necessarily  has  to
       guess  about  certain things - and occasionally it guesses
       wrong.  However, it is usually very easy to  identify  and
       fix these problems.  The typical problems are:

              ·   Timing.   A  surprisingly  large number of pro­
                  grams (rn, ksh, zsh, telnet, etc.) and  devices
                  (e.g.,  modems)  ignore  keystrokes that arrive
                  "too quickly" after prompts.  If you find  your
                  new script hanging up at one spot, try adding a
                  short sleep just before the previous send.
                  tion by using the -c flag.

                  Fortunately,  these timing spots are rare.  For
                  example, telnet ignores characters  only  after
                  entering  its  escape  sequence.   Modems  only
                  ignore characters immediately after  connecting
                  to  them  for  the  first time.  A few programs
                  exhibit this behavior all the  time  but  typi­
                  cally  have  a switch to disable it.  For exam­
                  ple, rn's -T flag disables this behavior.

                  The following example starts autoexpect in con­
                  servative mode.

                       autoexpect -c

                  The  -C  flag defines a key to toggle conserva­
                  tive mode.  The following example starts  auto­
                  expect  (in  non-conservative  mode) with ^L as
                  the toggle.  (Note that the ^L is entered  lit­
                  erally - i.e., enter a real control-L).

                       autoexpect -C ^L

                  The following example starts autoexpect in con­
                  servative mode with ^L as the toggle.

                       autoexpect -c -C ^L

              ·   Echoing.  Many program  echo  characters.   For
                  example,  if  you  type "more" to a shell, what
                  autoexpect actually sees is:

                       you typed 'm',
                       computer typed 'm',
                       you typed 'o',
                       computer typed 'o',
                       you typed 'r',
                       computer typed 'r',

                  Without specific knowledge of the  program,  it
                  is impossible to know if you are waiting to see
                  each character echoed before typing  the  next.
                  If  autoexpect sees characters being echoed, it
                  assumes that it can send them all  as  a  group
                  rather  than  interleaving  them  the  way they
                  originally appeared.   This  makes  the  script
                  more  pleasant to read.  However, it could con­
                  ceivably be incorrect if you really had to wait
                  to see each character echoed.
                  script  that  will require editing in order for
                  it to work.

                  The -p flag puts autoexpect into "prompt mode".
                  In this mode, autoexpect will only look for the
                  the last line of program output - which is usu­
                  ally the prompt.  This handles the date problem
                  (see above) and most others.

                  The  following  example  starts  autoexpect  in
                  prompt mode.

                       autoexpect -p

                  The  -P  flag  defines  a  key to toggle prompt
                  mode.  The following example starts  autoexpect
                  (in  non-prompt  mode)  with  ^P as the toggle.
                  Note that the ^P is entered literally  -  i.e.,
                  enter a real control-P.

                       autoexpect -P ^P

                  The  following  example  starts  autoexpect  in
                  prompt mode with ^P as the toggle.

                       autoexpect -p -P ^P


       The -quiet flag disables informational  messages  produced
       by autoexpect.

       The  -Q  flag names a quote character which can be used to
       enter characters that autoexpect would  otherwise  consume
       because they are used as toggles.

       The  following  example shows a number of flags with quote
       used to provide a way of entering the toggles literally.

            autoexpect -P ^P -C ^L -Q ^Q


       I don't know if there is a "style" for Expect programs but
       autoexpect  should  definitely not be held up as any model
       of style.  For example, autoexpect uses features of Expect
       that  are  intended  specifically  for  computer-generated
       scripting.  So don't try to faithfully write scripts  that
       appear  as  if they were generated by autoexpect.  This is
       not useful.

       On the other hand, autoexpect scripts do show some  worth­
       I would appreciate credit if these programs  or  parts  of
       them are used.

                           30 June 1995             AUTOEXPECT(1)



Security Code
Security Code
Type Security Code

Don't have an account yet? You can create one. As a registered user you have some advantages like theme manager, comments configuration and post comments with your name.

Help if you can!

Amazon Wish List

Did You Know?
You can choose larger fonts by selecting a different themes.


Tell a Friend About Us

Bookmark and Share

Web site powered by PHP-Nuke

Is this information useful? At the very least you can help by spreading the word to your favorite newsgroups, mailing lists and forums.
All logos and trademarks in this site are property of their respective owner. The comments are property of their posters. Articles are the property of their respective owners. Unless otherwise stated in the body of the article, article content (C) 1994-2013 by James Mohr. All rights reserved. The stylized page/paper, as well as the terms "The Linux Tutorial", "The Linux Server Tutorial", "The Linux Knowledge Base and Tutorial" and "The place where you learn Linux" are service marks of James Mohr. All rights reserved.
The Linux Knowledge Base and Tutorial may contain links to sites on the Internet, which are owned and operated by third parties. The Linux Tutorial is not responsible for the content of any such third-party site. By viewing/utilizing this web site, you have agreed to our disclaimer, terms of use and privacy policy. Use of automated download software ("harvesters") such as wget, httrack, etc. causes the site to quickly exceed its bandwidth limitation and are therefore expressly prohibited. For more details on this, take a look here

PHP-Nuke Copyright © 2004 by Francisco Burzi. This is free software, and you may redistribute it under the GPL. PHP-Nuke comes with absolutely no warranty, for details, see the license.
Page Generation: 0.11 Seconds