{
    "content": [
        {
            "type": "text",
            "text": "# EXPECT(1) (man)\n\n**Summary:** expect - programmed dialogue with interactive programs, Version 5\n\n**Synopsis:** expect [ -dDinN ] [ -c cmds ] [ [ -[f|b] ] cmdfile ] [ args ]\n\n## Examples\n\n- `It  many  not  be apparent how to put everything together that the man page describes.  I en‐`\n- `courage you to read and try out the examples in the example directory of the Expect distribu‐`\n- `tion.  Some of them are real programs.  Others are simply illustrative of certain techniques,`\n- `and of course, a couple are just quick hacks.  The INSTALL file has a quick overview of these`\n- `programs.`\n- `The Expect papers (see SEE ALSO) are also useful.  While some papers use syntax corresponding`\n- `to earlier versions of Expect, the accompanying rationales are still valid and go into a  lot`\n- `more detail than this man page.`\n\n## See Also\n\n- Tcl(3)\n- libexpect(3)\n\n## Section Outline\n\n- **NAME** (2 lines)\n- **SYNOPSIS** (2 lines)\n- **INTRODUCTION** (41 lines)\n- **USAGE** (62 lines) — 1 subsections\n  - -v (11 lines)\n- **COMMANDS** (55 lines) — 2 subsections\n  - disconnect (611 lines)\n  - interpreter  [args] (455 lines)\n- **LIBRARIES** (9 lines)\n- **PRETTY-PRINTING** (6 lines)\n- **EXAMPLES** (10 lines)\n- **CAVEATS** (43 lines)\n- **BUGS** (72 lines)\n- **EXPECT HINTS** (85 lines)\n- **SEE ALSO** (19 lines)\n- **AUTHOR** (2 lines)\n- **ACKNOWLEDGMENTS** (14 lines)\n\n## Full Content\n\n### NAME\n\nexpect - programmed dialogue with interactive programs, Version 5\n\n### SYNOPSIS\n\nexpect [ -dDinN ] [ -c cmds ] [ [ -[f|b] ] cmdfile ] [ args ]\n\n### INTRODUCTION\n\nExpect  is  a program that \"talks\" to other interactive programs according to a script.  Fol‐\nlowing the script, Expect knows what can be expected from a program and what the correct  re‐\nsponse  should  be.  An interpreted language provides branching and high-level control struc‐\ntures to direct the dialogue.  In addition, the user can take control and  interact  directly\nwhen desired, afterward returning control to the script.\n\nExpectk  is  a  mixture of Expect and Tk.  It behaves just like Expect and Tk's wish.  Expect\ncan also be used directly in C or C++ (that is, without Tcl).  See libexpect(3).\n\nThe name \"Expect\" comes from the idea of send/expect sequences popularized  by  uucp,  kermit\nand  other modem control programs.  However unlike uucp, Expect is generalized so that it can\nbe run as a user-level command with any program and task in mind.  Expect can  actually  talk\nto several programs at the same time.\n\nFor example, here are some things Expect can do:\n\n•   Cause your computer to dial you back, so that you can login without paying for the\ncall.\n\n•   Start a game (e.g., rogue)  and  if  the  optimal  configuration  doesn't  appear,\nrestart it (again and again) until it does, then hand over control to you.\n\n•   Run  fsck,  and  in  response to its questions, answer \"yes\", \"no\" or give control\nback to you, based on predetermined criteria.\n\n•   Connect to another network or BBS (e.g., MCI Mail, CompuServe)  and  automatically\nretrieve  your  mail so that it appears as if it was originally sent to your local\nsystem.\n\n•   Carry environment variables, current directory, or any kind of information  across\nrlogin, telnet, tip, su, chgrp, etc.\n\nThere  are a variety of reasons why the shell cannot perform these tasks.  (Try, you'll see.)\nAll are possible with Expect.\n\nIn general, Expect is useful for running any program which requires interaction  between  the\nprogram  and  the  user.   All that is necessary is that the interaction can be characterized\nprogrammatically.  Expect can also give the user back control (without  halting  the  program\nbeing  controlled)  if  desired.  Similarly, the user can return control to the script at any\ntime.\n\n### USAGE\n\nExpect reads cmdfile for a list of commands to execute.  Expect may also be  invoked  implic‐\nitly  on  systems  which support the #! notation by marking the script executable, and making\nthe first line in your script:\n\n#!/usr/bin/expect -f\n\nOf course, the path must accurately describe where Expect lives.  /usr/bin is just  an  exam‐\nple.\n\nThe  -c  flag prefaces a command to be executed before any in the script.  The command should\nbe quoted to prevent being broken up by the shell.  This option may be used  multiple  times.\nMultiple  commands may be executed with a single -c by separating them with semicolons.  Com‐\nmands are executed in the order they appear.  (When using Expectk, this option  is  specified\nas -command.)\n\nThe -d flag enables some diagnostic output, which primarily reports internal activity of com‐\nmands such as expect and interact.  This flag has the same effect as \"expinternal 1\" at  the\nbeginning of an Expect script, plus the version of Expect is printed.  (The strace command is\nuseful for tracing statements, and the trace command is useful for tracing  variable  assign‐\nments.)  (When using Expectk, this option is specified as -diag.)\n\nThe  -D  flag enables an interactive debugger.  An integer value should follow.  The debugger\nwill take control before the next Tcl procedure if the value  is  non-zero  or  if  a  ^C  is\npressed  (or  a  breakpoint  is  hit,  or  other  appropriate debugger command appears in the\nscript).  See the README file or SEE ALSO (below)  for  more  information  on  the  debugger.\n(When using Expectk, this option is specified as -Debug.)\n\nThe -f flag prefaces a file from which to read commands from.  The flag itself is optional as\nit is only useful when using the #! notation (see above), so that other arguments may be sup‐\nplied on the command line.  (When using Expectk, this option is specified as -file.)\n\nBy  default,  the command file is read into memory and executed in its entirety.  It is occa‐\nsionally desirable to read files one line at a time.  For example, stdin is  read  this  way.\nIn  order  to force arbitrary files to be handled this way, use the -b flag.  (When using Ex‐\npectk, this option is specified as -buffer.)  Note that stdio-buffering may still take  place\nhowever this shouldn't cause problems when reading from a fifo or stdin.\n\nIf  the  string \"-\" is supplied as a filename, standard input is read instead.  (Use \"./-\" to\nread from a file actually named \"-\".)\n\nThe -i flag causes Expect to interactively prompt for commands instead of reading them from a\nfile.  Prompting is terminated via the exit command or upon EOF.  See interpreter (below) for\nmore information.  -i is assumed if neither a command file nor -c is used.  (When  using  Ex‐\npectk, this option is specified as -interactive.)\n\n--  may be used to delimit the end of the options.  This is useful if you want to pass an op‐\ntion-like argument to your script without it being interpreted by Expect.  This can  usefully\nbe placed in the #! line to prevent any flag-like interpretation by Expect.  For example, the\nfollowing will leave the original arguments (including the script name) in the variable argv.\n\n#!/usr/bin/expect --\n\nNote that the usual getopt(3) and execve(2) conventions must be observed  when  adding  argu‐\nments to the #! line.\n\nThe  file  $explibrary/expect.rc  is sourced automatically if present, unless the -N flag is\nused.  (When using Expectk, this option is specified as -NORC.)  Immediately after this,  the\nfile  ~/.expect.rc  is sourced automatically, unless the -n flag is used.  If the environment\nvariable DOTDIR is defined, it is treated as a directory and .expect.rc is read  from  there.\n(When using Expectk, this option is specified as -norc.)  This sourcing occurs only after ex‐\necuting any -c flags.\n\n#### -v\n\nwhich uses long flag names, is -version.)\n\nOptional  args  are  constructed  into a list and stored in the variable named argv.  argc is\ninitialized to the length of argv.\n\nargv0 is defined to be the name of the script (or binary if no script is used).  For example,\nthe following prints out the name of the script and the first three arguments:\n\nsenduser \"$argv0 [lrange $argv 0 2]\\n\"\n\n### COMMANDS\n\nExpect  uses  Tcl (Tool Command Language).  Tcl provides control flow (e.g., if, for, break),\nexpression evaluation and several other features such  as  recursion,  procedure  definition,\netc.  Commands used here but not defined (e.g., set, if, exec) are Tcl commands (see tcl(3)).\nExpect supports additional commands, described below.  Unless otherwise  specified,  commands\nreturn the empty string.\n\nCommands  are  listed alphabetically so that they can be quickly located.  However, new users\nmay find it easier to start by reading the descriptions of spawn, send, expect, and interact,\nin that order.\n\nNote that the best introduction to the language (both Expect and Tcl) is provided in the book\n\"Exploring Expect\" (see SEE ALSO below).  Examples are included in this man page but they are\nvery limited since this man page is meant primarily as reference material.\n\nNote  that  in the text of this man page, \"Expect\" with an uppercase \"E\" refers to the Expect\nprogram while \"expect\" with a lower-case \"e\" refers to the expect command within  the  Expect\nprogram.)\n\nclose [-slave] [-onexec 0|1] [-i spawnid]\ncloses  the  connection  to the current process.  Most interactive programs will detect\nEOF on their stdin and exit; thus close usually suffices to kill the process  as  well.\nThe -i flag declares the process to close corresponding to the named spawnid.\n\nBoth expect and interact will detect when the current process exits and implicitly do a\nclose.  But if you kill the process by, say, \"exec kill $pid\", you will need to explic‐\nitly call close.\n\nThe -onexec flag determines whether the spawn id will be closed in any new spawned pro‐\ncesses or if the process is overlayed.  To leave a spawn id open, use the value  0.   A\nnon-zero integer value will force the spawn closed (the default) in any new processes.\n\nThe  -slave  flag  closes  the slave associated with the spawn id.  (See \"spawn -pty\".)\nWhen the connection is closed, the slave is automatically closed as well if still open.\n\nNo matter whether the connection is closed implicitly or explicitly,  you  should  call\nwait to clear up the corresponding kernel process slot.  close does not call wait since\nthere is no guarantee that closing a process connection will cause  it  to  exit.   See\nwait below for more info.\n\ndebug [[-now] 0|1]\ncontrols a Tcl debugger allowing you to step through statements, set breakpoints, etc.\n\nWith no arguments, a 1 is returned if the debugger is not running, otherwise a 0 is re‐\nturned.\n\nWith a 1 argument, the debugger is  started.   With  a  0  argument,  the  debugger  is\nstopped.  If a 1 argument is preceded by the -now flag, the debugger is started immedi‐\nately (i.e., in the middle of the debug command itself).  Otherwise,  the  debugger  is\nstarted with the next Tcl statement.\n\nThe  debug command does not change any traps.  Compare this to starting Expect with the\n-D flag (see above).\n\nSee the README file or SEE ALSO (below) for more information on the debugger.\n\n#### disconnect\n\ndisconnects a forked process from the terminal.  It  continues  running  in  the  back‐\nground.   The  process  is  given its own process group (if possible).  Standard I/O is\nredirected to /dev/null.\n\nThe following fragment uses disconnect to continue running  the  script  in  the  back‐\nground.\n\nif {[fork]!=0} exit\ndisconnect\n. . .\n\nThe  following script reads a password, and then runs a program every hour that demands\na password each time it is run.  The script supplies the password so that you only have\nto  type  it  once.   (See the stty command which demonstrates how to turn off password\nechoing.)\n\nsenduser \"password?\\ \"\nexpectuser -re \"(.*)\\n\"\nfor {} 1 {} {\nif {[fork]!=0} {sleep 3600;continue}\ndisconnect\nspawn privprog\nexpect Password:\nsend \"$expectout(1,string)\\r\"\n. . .\nexit\n}\n\nAn advantage to using disconnect over the shell asynchronous  process  feature  (&)  is\nthat Expect can save the terminal parameters prior to disconnection, and then later ap‐\nply them to new ptys.  With &, Expect does not have a chance to read the terminal's pa‐\nrameters  since  the  terminal is already disconnected by the time Expect receives con‐\ntrol.\n\nexit [-opts] [status]\ncauses Expect to exit or otherwise prepare to do so.\n\nThe -onexit flag causes the next argument to be used as an exit  handler.   Without  an\nargument, the current exit handler is returned.\n\nThe  -noexit flag causes Expect to prepare to exit but stop short of actually returning\ncontrol to the operating system.  The user-defined exit handler is run as well  as  Ex‐\npect's  own internal handlers.  No further Expect commands should be executed.  This is\nuseful if you are running Expect with other Tcl extensions.   The  current  interpreter\n(and  main  window  if  in  the Tk environment) remain so that other Tcl extensions can\nclean up.  If Expect's exit is called again (however this might  occur),  the  handlers\nare not rerun.\n\nUpon  exiting,  all  connections  to spawned processes are closed.  Closure will be de‐\ntected as an EOF by spawned processes.  exit takes no other  actions  beyond  what  the\nnormal  exit(2) procedure does.  Thus, spawned processes that do not check for EOF may\ncontinue to run.  (A variety of conditions are important to determining,  for  example,\nwhat  signals a spawned process will be sent, but these are system-dependent, typically\ndocumented under exit(3).)  Spawned processes that continue to run will be inherited by\ninit.\n\nstatus  (or  0 if not specified) is returned as the exit status of Expect.  exit is im‐\nplicitly executed if the end of the script is reached.\n\nexpcontinue [-continuetimer]\nThe command expcontinue allows expect itself to continue executing rather than return‐\ning  as  it normally would. By default expcontinue resets the timeout timer. The -con‐\ntinuetimer flag prevents timer from being restarted. (See  expect  for  more  informa‐\ntion.)\n\nexpinternal [-f file] value\ncauses  further commands to send diagnostic information internal to Expect to stderr if\nvalue is non-zero.  This output is disabled if value is 0.  The diagnostic  information\nincludes  every  character received, and every attempt made to match the current output\nagainst the patterns.\n\nIf the optional file is supplied, all normal and debugging output is  written  to  that\nfile  (regardless  of  the  value  of  value).   Any previous diagnostic output file is\nclosed.\n\nThe -info flag causes expinternal to return a description of the most recent  non-info\narguments given.\n\nexpopen [args] [-i spawnid]\nreturns  a  Tcl  file  identifier  that corresponds to the original spawn id.  The file\nidentifier can then be used as if it were opened by Tcl's open command.  (The spawn  id\nshould no longer be used.  A wait should not be executed.\n\nThe  -leaveopen  flag  leaves  the spawn id open for access through Expect commands.  A\nwait must be executed on the spawn id.\n\nexppid [-i spawnid]\nreturns the process id corresponding to the currently spawned process.  If the -i  flag\nis used, the pid returned corresponds to that of the given spawn id.\n\nexpsend\nis an alias for send.\n\nexpsenderror\nis an alias for senderror.\n\nexpsendlog\nis an alias for sendlog.\n\nexpsendtty\nis an alias for sendtty.\n\nexpsenduser\nis an alias for senduser.\n\nexpversion [[-exit] version]\nis  useful  for  assuring that the script is compatible with the current version of Ex‐\npect.\n\nWith no arguments, the current version of Expect is returned.  This version may then be\nencoded in your script.  If you actually know that you are not using features of recent\nversions, you can specify an earlier version.\n\nVersions consist of three numbers separated  by  dots.   First  is  the  major  number.\nScripts  written  for versions of Expect with a different major number will almost cer‐\ntainly not work.  expversion returns an error if the major numbers do not match.\n\nSecond is the minor number.  Scripts written for a version with a greater minor  number\nthan  the current version may depend upon some new feature and might not run.  expver‐‐\nsion returns an error if the major numbers  match,  but  the  script  minor  number  is\ngreater than that of the running Expect.\n\nThird  is a number that plays no part in the version comparison.  However, it is incre‐\nmented when the Expect software distribution is changed in any way, such  as  by  addi‐\ntional documentation or optimization.  It is reset to 0 upon each new minor version.\n\nWith the -exit flag, Expect prints an error and exits if the version is out of date.\n\nexpect [[-opts] pat1 body1] ... [-opts] patn [bodyn]\nwaits  until  one  of the patterns matches the output of a spawned process, a specified\ntime period has passed, or an end-of-file is seen.  If the final body is empty, it  may\nbe omitted.\n\nPatterns  from  the  most  recent  expectbefore command are implicitly used before any\nother patterns.  Patterns from the most recent expectafter command are implicitly used\nafter any other patterns.\n\nIf the arguments to the entire expect statement require more than one line, all the ar‐\nguments may be \"braced\" into one so as to avoid terminating each line with a backslash.\nIn this one case, the usual Tcl substitutions will occur despite the braces.\n\nIf  a  pattern is the keyword eof, the corresponding body is executed upon end-of-file.\nIf a pattern is the keyword timeout, the corresponding body is executed  upon  timeout.\nIf  no  timeout keyword is used, an implicit null action is executed upon timeout.  The\ndefault timeout period is 10 seconds but may be set, for example to 30, by the  command\n\"set timeout 30\".  An infinite timeout may be designated by the value -1.  If a pattern\nis the keyword default, the corresponding body is executed upon either timeout or  end-\nof-file.\n\nIf  a pattern matches, then the corresponding body is executed.  expect returns the re‐\nsult of the body (or the empty string if no pattern matched).  In the event that multi‐\nple patterns match, the one appearing first is used to select a body.\n\nEach  time  new  output  arrives,  it is compared to each pattern in the order they are\nlisted.  Thus, you may test for absence of a match by making the last pattern something\nguaranteed  to  appear,  such as a prompt.  In situations where there is no prompt, you\nmust use timeout (just like you would if you were interacting manually).\n\nPatterns are specified in three ways.  By default, patterns are specified as with Tcl's\nstring  match  command.  (Such patterns are also similar to C-shell regular expressions\nusually referred to as \"glob\" patterns).  The -gl flag may may be used to protect  pat‐\nterns  that  might  otherwise  match expect flags from doing so.  Any pattern beginning\nwith a \"-\" should be protected this way.  (All strings starting with \"-\"  are  reserved\nfor future options.)\n\n\nFor  example, the following fragment looks for a successful login.  (Note that abort is\npresumed to be a procedure defined elsewhere in the script.)\n\nexpect {\nbusy               {puts busy\\n ; expcontinue}\nfailed             abort\n\"invalid password\" abort\ntimeout            abort\nconnected\n}\n\nQuotes are necessary on the fourth pattern since it contains a space, which would  oth‐\nerwise  separate  the  pattern from the action.  Patterns with the same action (such as\nthe 3rd and 4th) require listing the actions again.  This can be avoid by using regexp-\nstyle  patterns  (see  below).   More information on forming glob-style patterns can be\nfound in the Tcl manual.\n\nRegexp-style patterns follow the syntax defined by Tcl's regexp (short for \"regular ex‐\npression\")  command.   regexp  patterns are introduced with the flag -re.  The previous\nexample can be rewritten using a regexp as:\n\nexpect {\nbusy       {puts busy\\n ; expcontinue}\n-re \"failed|invalid password\" abort\ntimeout    abort\nconnected\n}\n\nBoth types of patterns are \"unanchored\".  This means that patterns do not have to match\nthe  entire  string, but can begin and end the match anywhere in the string (as long as\neverything else matches).  Use ^ to match the beginning of a string, and $ to match the\nend.   Note  that if you do not wait for the end of a string, your responses can easily\nend up in the middle of the string as they are echoed from the spawned process.   While\nstill  producing correct results, the output can look unnatural.  Thus, use of $ is en‐\ncouraged if you can exactly describe the characters at the end of a string.\n\nNote that in many editors, the ^ and $ match the beginning and  end  of  lines  respec‐\ntively. However, because expect is not line oriented, these characters match the begin‐\nning and end of the data (as opposed to lines) currently in the expect matching buffer.\n(Also, see the note below on \"system indigestion.\")\n\nThe  -ex flag causes the pattern to be matched as an \"exact\" string.  No interpretation\nof *, ^, etc is made (although the usual Tcl conventions must still be observed).   Ex‐\nact patterns are always unanchored.\n\n\nThe  -nocase  flag causes uppercase characters of the output to compare as if they were\nlowercase characters.  The pattern is not affected.\n\nWhile reading output, more than 2000 bytes can force earlier bytes to  be  \"forgotten\".\nThis  may  be changed with the function matchmax.  (Note that excessively large values\ncan slow down the pattern matcher.)  If patlist is fullbuffer, the corresponding  body\nis  executed  if matchmax bytes have been received and no other patterns have matched.\nWhether or not the fullbuffer keyword is used, the forgotten characters are written to\nexpectout(buffer).\n\nIf  patlist  is the keyword null, and nulls are allowed (via the removenulls command),\nthe corresponding body is executed if a single ASCII 0 is matched.  It is not  possible\nto match 0 bytes via glob or regexp patterns.\n\nUpon  matching a pattern (or eof or fullbuffer), any matching and previously unmatched\noutput is saved in the variable expectout(buffer).  Up to 9 regexp  substring  matches\nare  saved  in the variables expectout(1,string) through expectout(9,string).  If the\n-indices flag is used before a pattern, the starting and  ending  indices  (in  a  form\nsuitable  for lrange) of the 10 strings are stored in the variables expectout(X,start)\nand expectout(X,end) where X is a digit, corresponds to the substring position in  the\nbuffer.  0 refers to strings which matched the entire pattern and is generated for glob\npatterns as well as regexp patterns.  For example, if a process has produced output  of\n\"abcdefgh\\n\", the result of:\n\nexpect \"cd\"\n\nis as if the following statements had executed:\n\nset expectout(0,string) cd\nset expectout(buffer) abcd\n\nand  \"efgh\\n\"  is  left  in the output buffer.  If a process produced the output \"abbb‐\ncabkkkka\\n\", the result of:\n\nexpect -indices -re \"b(b*).*(k+)\"\n\nis as if the following statements had executed:\n\nset expectout(0,start) 1\nset expectout(0,end) 10\nset expectout(0,string) bbbcabkkkk\nset expectout(1,start) 2\nset expectout(1,end) 3\nset expectout(1,string) bb\nset expectout(2,start) 10\nset expectout(2,end) 10\nset expectout(2,string) k\nset expectout(buffer) abbbcabkkkk\n\nand \"a\\n\" is left in the output buffer.  The pattern \"*\" (and -re \".*\") will flush  the\noutput buffer without reading any more output from the process.\n\nNormally,  the matched output is discarded from Expect's internal buffers.  This may be\nprevented by prefixing a pattern with the -notransfer flag.  This  flag  is  especially\nuseful in experimenting (and can be abbreviated to \"-not\" for convenience while experi‐\nmenting).\n\nThe spawn id associated with the matching output (or eof or fullbuffer) is  stored  in\nexpectout(spawnid).\n\nThe  -timeout  flag  causes  the current expect command to use the following value as a\ntimeout instead of using the value of the timeout variable.\n\nBy default, patterns are matched against output from the current process,  however  the\n-i flag declares the output from the named spawnid list be matched against any follow‐\ning patterns (up to the next -i).  The spawnid list should either be a whitespace sep‐\narated list of spawnids or a variable referring to such a list of spawnids.\n\nFor  example,  the following example waits for \"connected\" from the current process, or\n\"busy\", \"failed\" or \"invalid password\" from the spawnid named by $proc2.\n\nexpect {\n-i $proc2 busy {puts busy\\n ; expcontinue}\n-re \"failed|invalid password\" abort\ntimeout abort\nconnected\n}\n\nThe value of the global variable anyspawnid may be used  to  match  patterns  to  any\nspawnids  that  are  named with all other -i flags in the current expect command.  The\nspawnid from a -i flag with no associated pattern (i.e., followed immediately  by  an‐\nother -i) is made available to any other patterns in the same expect command associated\nwith anyspawnid.\n\nThe -i flag may also name a global variable in which case the variable is  read  for  a\nlist of spawn ids.  The variable is reread whenever it changes.  This provides a way of\nchanging the I/O source while the command is in execution.  Spawn ids provided this way\nare called \"indirect\" spawn ids.\n\nActions such as break and continue cause control structures (i.e., for, proc) to behave\nin the usual way.  The command expcontinue allows expect itself to continue  executing\nrather than returning as it normally would.\n\nThis  is useful for avoiding explicit loops or repeated expect statements.  The follow‐\ning example is part of a fragment to automate rlogin.  The expcontinue  avoids  having\nto write a second expect statement (to look for the prompt again) if the rlogin prompts\nfor a password.\n\nexpect {\nPassword: {\nstty -echo\nsenduser \"password (for $user) on $host: \"\nexpectuser -re \"(.*)\\n\"\nsenduser \"\\n\"\nsend \"$expectout(1,string)\\r\"\nstty echo\nexpcontinue\n} incorrect {\nsenduser \"invalid password or account\\n\"\nexit\n} timeout {\nsenduser \"connection to $host timed out\\n\"\nexit\n} eof {\nsenduser \\\n\"connection to host failed: $expectout(buffer)\"\nexit\n} -re $prompt\n}\n\nFor example, the following fragment might help a user guide an interaction that is  al‐\nready totally automated.  In this case, the terminal is put into raw mode.  If the user\npresses \"+\", a variable is incremented.  If \"p\" is pressed, several returns are sent to\nthe  process,  perhaps  to poke it in some way, and \"i\" lets the user interact with the\nprocess, effectively stealing away control from the script.  In each case, the expcon‐‐\ntinue  allows  the current expect to continue pattern matching after executing the cur‐\nrent action.\n\nstty raw -echo\nexpectafter {\n-i $userspawnid\n\"p\" {send \"\\r\\r\\r\"; expcontinue}\n\"+\" {incr foo; expcontinue}\n\"i\" {interact; expcontinue}\n\"quit\" exit\n}\n\n\nBy default, expcontinue resets the timeout timer.  The  timer  is  not  restarted,  if\nexpcontinue is called with the -continuetimer flag.\n\nexpectafter [expectargs]\nworks identically to the expectbefore except that if patterns from both expect and ex‐‐\npectafter can match, the expect pattern is used.  See the  expectbefore  command  for\nmore information.\n\nexpectbackground [expectargs]\ntakes  the  same  arguments  as  expect,  however it returns immediately.  Patterns are\ntested whenever new input arrives.  The pattern timeout and default are meaningless  to\nexpectbackground and are silently discarded.  Otherwise, the expectbackground command\nuses expectbefore and expectafter patterns just like expect does.\n\nWhen expectbackground actions are being evaluated, background processing for the  same\nspawn  id  is  blocked.   Background processing is unblocked when the action completes.\nWhile background processing is blocked, it is possible to do a (foreground)  expect  on\nthe same spawn id.\n\nIt  is  not possible to execute an expect while an expectbackground is unblocked.  ex‐‐\npectbackground for a particular spawn id is deleted by declaring  a  new  expectback‐\nground with the same spawn id.  Declaring expectbackground with no pattern removes the\ngiven spawn id from the ability to match patterns in the background.\n\nexpectbefore [expectargs]\ntakes the same arguments as expect, however  it  returns  immediately.   Pattern-action\npairs from the most recent expectbefore with the same spawn id are implicitly added to\nany following expect commands.  If a pattern matches, it is treated as if it  had  been\nspecified in the expect command itself, and the associated body is executed in the con‐\ntext of the expect command.  If patterns from both expectbefore and expect can  match,\nthe expectbefore pattern is used.\n\nIf no pattern is specified, the spawn id is not checked for any patterns.\n\nUnless  overridden  by a -i flag, expectbefore patterns match against the spawn id de‐\nfined at the time that the expectbefore command was executed (not when its pattern  is\nmatched).\n\nThe  -info  flag causes expectbefore to return the current specifications of what pat‐\nterns it will match.  By default, it reports on the  current  spawn  id.   An  optional\nspawn id specification may be given for information on that spawn id.  For example\n\nexpectbefore -info -i $proc\n\nAt  most one spawn id specification may be given.  The flag -indirect suppresses direct\nspawn ids that come only from indirect specifications.\n\nInstead of a spawn id specification, the flag \"-all\" will cause \"-info\"  to  report  on\nall spawn ids.\n\nThe output of the -info flag can be reused as the argument to expectbefore.\n\nexpecttty [expectargs]\nis  like  expect but it reads characters from /dev/tty (i.e. keystrokes from the user).\nBy default, reading is performed in cooked mode.  Thus, lines must end with a return in\norder  for  expect to see them.  This may be changed via stty (see the stty command be‐\nlow).\n\nexpectuser [expectargs]\nis like expect but it reads characters from stdin (i.e. keystrokes from the user).   By\ndefault,  reading  is  performed in cooked mode.  Thus, lines must end with a return in\norder for expect to see them.  This may be changed via stty (see the stty  command  be‐\nlow).\n\nfork  creates a new process.  The new process is an exact copy of the current Expect process.\nOn success, fork returns 0 to the new (child) process and returns the process ID of the\nchild  process to the parent process.  On failure (invariably due to lack of resources,\ne.g., swap space, memory), fork returns -1 to the parent process, and no child  process\nis created.\n\nForked  processes  exit  via  the exit command, just like the original process.  Forked\nprocesses are allowed to write to the log files.  If you do not  disable  debugging  or\nlogging in most of the processes, the result can be confusing.\n\nSome  pty  implementations may be confused by multiple readers and writers, even momen‐\ntarily.  Thus, it is safest to fork before spawning processes.\n\ninteract [string1 body1] ... [stringn [bodyn]]\ngives control of the current process to the user, so that keystrokes are  sent  to  the\ncurrent process, and the stdout and stderr of the current process are returned.\n\nString-body  pairs  may  be  specified as arguments, in which case the body is executed\nwhen the corresponding string is entered.  (By default, the string is not sent  to  the\ncurrent process.)   The interpreter command is assumed, if the final body is missing.\n\nIf  the  arguments to the entire interact statement require more than one line, all the\narguments may be \"braced\" into one so as to avoid terminating each line  with  a  back‐\nslash.  In this one case, the usual Tcl substitutions will occur despite the braces.\n\nFor  example,  the following command runs interact with the following string-body pairs\ndefined:  When ^Z is pressed, Expect is suspended.  (The -reset flag restores the  ter‐\nminal  modes.)   When  ^A  is  pressed,  the  user sees \"you typed a control-A\" and the\nprocess is sent a ^A.  When $ is pressed, the user sees the date.  When ^C is  pressed,\nExpect  exits.   If \"foo\" is entered, the user sees \"bar\".  When ~~ is pressed, the Ex‐‐\npect interpreter runs interactively.\n\nset CTRLZ \\032\ninteract {\n-reset $CTRLZ {exec kill -STOP [pid]}\n\\001   {senduser \"you typed a control-A\\n\";\nsend \"\\001\"\n}\n$      {senduser \"The date is [clock format [clock seconds]].\"}\n\\003   exit\nfoo    {senduser \"bar\"}\n~~\n}\n\n\nIn string-body pairs, strings are matched in the order they are  listed  as  arguments.\nStrings that partially match are not sent to the current process in anticipation of the\nremainder coming.  If characters are then entered such that there can no longer  possi‐\nbly  be  a  match,  only the part of the string will be sent to the process that cannot\npossibly begin another match.  Thus, strings that are substrings of partial matches can\nmatch later, if the original strings that was attempting to be match ultimately fails.\n\nBy default, string matching is exact with no wild cards.  (In contrast, the expect com‐\nmand uses glob-style patterns by default.)  The -ex flag may be used  to  protect  pat‐\nterns  that  might otherwise match interact flags from doing so.  Any pattern beginning\nwith a \"-\" should be protected this way.    (All strings starting with \"-\" are reserved\nfor future options.)\n\nThe  -re  flag  forces the string to be interpreted as a regexp-style pattern.  In this\ncase, matching substrings are stored in the variable interactout similarly to the  way\nexpect  stores  its  output in the variable expectout.  The -indices flag is similarly\nsupported.\n\nThe pattern eof introduces an action that is executed upon end-of-file.  A separate eof\npattern  may  also follow the -output flag in which case it is matched if an eof is de‐\ntected while writing output.  The default eof action is \"return\", so that interact sim‐\nply returns upon any EOF.\n\nThe pattern timeout introduces a timeout (in seconds) and action that is executed after\nno characters have been read for a given time.  The timeout pattern applies to the most\nrecently  specified process.  There is no default timeout.  The special variable \"time‐\nout\" (used by the expect command) has no affect on this timeout.\n\nFor example, the following statement could be used to autologout  users  who  have  not\ntyped anything for an hour but who still get frequent system messages:\n\ninteract -input $userspawnid timeout 3600 return -output \\\n$spawnid\n\n\nIf  the  pattern  is the keyword null, and nulls are allowed (via the removenulls com‐\nmand), the corresponding body is executed if a single ASCII 0 is matched.   It  is  not\npossible to match 0 bytes via glob or regexp patterns.\n\nPrefacing a pattern with the flag -iwrite causes the variable interactout(spawnid) to\nbe set to the spawnid which matched the pattern (or eof).\n\nActions such as break and continue cause control structures (i.e., for, proc) to behave\nin  the  usual  way.  However return causes interact to return to its caller, while in‐‐\nterreturn causes interact to cause a return in its caller.  For example, if \"proc foo\"\ncalled  interact  which  then  executed the action interreturn, proc foo would return.\n(This means that if interact calls interpreter interactively typing return  will  cause\nthe  interact  to continue, while interreturn will cause the interact to return to its\ncaller.)\n\nDuring interact, raw mode is used so that all characters may be passed to  the  current\nprocess.   If  the  current process does not catch job control signals, it will stop if\nsent a stop signal (by default ^Z).  To restart it, send a continue signal (such as  by\n\"kill  -CONT  <pid>\").  If you really want to send a SIGSTOP to such a process (by ^Z),\nconsider spawning csh first and then running your program.  On the other hand,  if  you\nwant  to  send  a SIGSTOP to Expect itself, first call interpreter (perhaps by using an\nescape character), and then press ^Z.\n\nString-body pairs can be used as a shorthand for avoiding having to  enter  the  inter‐\npreter  and  execute  commands interactively.  The previous terminal mode is used while\nthe body of a string-body pair is being executed.\n\nFor speed, actions execute in raw mode by default.  The -reset flag resets the terminal\nto  the  mode it had before interact was executed (invariably, cooked mode).  Note that\ncharacters entered when the mode is being switched may be lost (an unfortunate  feature\nof  the terminal driver on some systems).  The only reason to use -reset is if your ac‐\ntion depends on running in cooked mode.\n\nThe -echo flag sends characters that match the following pattern back  to  the  process\nthat  generated them as each character is read.  This may be useful when the user needs\nto see feedback from partially typed patterns.\n\nIf a pattern is being echoed but eventually fails to match, the characters are sent  to\nthe  spawned  process.   If the spawned process then echoes them, the user will see the\ncharacters twice.  -echo is probably only appropriate in situations where the  user  is\nunlikely to not complete the pattern.  For example, the following excerpt is from rftp,\nthe recursive-ftp script, where the user is prompted to enter ~g, ~p, or  ~l,  to  get,\nput,  or list the current directory recursively.  These are so far away from the normal\nftp commands, that the user is unlikely to type ~ followed  by  anything  else,  except\nmistakenly, in which case, they'll probably just ignore the result anyway.\n\ninteract {\n-echo ~g {getcurdirectory 1}\n-echo ~l {getcurdirectory 0}\n-echo ~p {putcurdirectory}\n}\n\nThe  -nobuffer  flag sends characters that match the following pattern on to the output\nprocess as characters are read.\n\nThis is useful when you wish to let a program echo back the pattern.  For example,  the\nfollowing  might  be  used  to monitor where a person is dialing (a Hayes-style modem).\nEach time \"atd\" is seen the script logs the rest of the line.\n\nproc lognumber {} {\ninteract -nobuffer -re \"(.*)\\r\" return\nputs $log \"[clock format [clock seconds]]: dialed $interactout(1,string)\"\n}\n\ninteract -nobuffer \"atd\" lognumber\n\n\nDuring interact, previous use of loguser is ignored.   In  particular,  interact  will\nforce  its  output  to be logged (sent to the standard output) since it is presumed the\nuser doesn't wish to interact blindly.\n\nThe -o flag causes any following key-body pairs to be applied to the output of the cur‐\nrent  process.   This can be useful, for example, when dealing with hosts that send un‐\nwanted characters during a telnet session.\n\nBy default, interact expects the user to be writing stdin and reading stdout of the Ex‐‐\npect  process itself.  The -u flag (for \"user\") makes interact look for the user as the\nprocess named by its argument (which must be a spawned id).\n\nThis allows two unrelated processes to be joined together  without  using  an  explicit\nloop.   To aid in debugging, Expect diagnostics always go to stderr (or stdout for cer‐\ntain logging and debugging information).  For the same reason, the interpreter  command\nwill read interactively from stdin.\n\nFor  example,  the  following fragment creates a login process.  Then it dials the user\n(not shown), and finally connects the two together.  Of course, any process may be sub‐\nstituted for login.  A shell, for example, would allow the user to work without supply‐\ning an account and password.\n\nspawn login\nset login $spawnid\nspawn tip modem\n# dial back out to user\n# connect user to login\ninteract -u $login\n\nTo send output to multiple processes, list each spawn id list  prefaced  by  a  -output\nflag.  Input for a group of output spawn ids may be determined by a spawn id list pref‐\naced by a -input flag.  (Both -input and -output may take lists in the same form as the\n-i flag in the expect command, except that anyspawnid is not meaningful in interact.)\nAll following flags and strings (or patterns) apply to this input until another  -input\nflag  appears.   If no -input appears, -output implies \"-input $userspawnid -output\".\n(Similarly, with patterns that do not have -input.)  If one  -input  is  specified,  it\noverrides  $userspawnid.   If  a  second -input is specified, it overrides $spawnid.\nAdditional -input flags may be specified.\n\nThe two implied input processes default to having their outputs specified as  $spawnid\nand  $userspawnid (in reverse).  If a -input flag appears with no -output flag, char‐\nacters from that process are discarded.\n\nThe -i flag introduces a replacement for the current spawnid when no other  -input  or\n-output flags are used.  A -i flag implies a -o flag.\n\nIt is possible to change the processes that are being interacted with by using indirect\nspawn ids.  (Indirect spawn ids are described in the section on  the  expect  command.)\nIndirect spawn ids may be specified with the -i, -u, -input, or -output flags.\n\n#### interpreter  [args]\n\ncauses  the  user to be interactively prompted for Expect and Tcl commands.  The result\nof each command is printed.\n\nActions such as break and continue cause control structures (i.e., for, proc) to behave\nin the usual way.  However return causes interpreter to return to its caller, while in‐‐\nterreturn causes interpreter to cause a return in its caller.  For example,  if  \"proc\nfoo\" called interpreter which then executed the action interreturn, proc foo would re‐\nturn.  Any other command causes interpreter to continue prompting for new commands.\n\nBy default, the prompt contains two integers.  The first integer describes the depth of\nthe evaluation stack (i.e., how many times TclEval has been called).  The second inte‐\nger is the Tcl history identifier.  The prompt can  be  set  by  defining  a  procedure\ncalled  \"prompt1\"  whose return value becomes the next prompt.  If a statement has open\nquotes, parens, braces, or brackets, a secondary prompt (by default \"+>  \")  is  issued\nupon  newline.   The  secondary  prompt  may  be  set  by  defining  a procedure called\n\"prompt2\".\n\nDuring interpreter, cooked mode is used, even if the its caller was using raw mode.\n\nIf stdin is closed, interpreter will return unless the -eof flag is used, in which case\nthe subsequent argument is invoked.\n\nlogfile [args] [[-a] file]\nIf  a filename is provided, logfile will record a transcript of the session (beginning\nat that point) in the file.  logfile will stop recording if no argument is given.  Any\nprevious log file is closed.\n\nInstead  of  a  filename,  a  Tcl file identifier may be provided by using the -open or\n-leaveopen flags.  This is similar to the spawn command.  (See spawn for more info.)\n\nThe -a flag forces output to be logged that was suppressed by the loguser command.\n\nBy default, the logfile command appends to old files rather than truncating them,  for\nthe convenience of being able to turn logging off and on multiple times in one session.\nTo truncate files, use the -noappend flag.\n\nThe -info flag causes logfile to return a description of the most recent non-info  ar‐\nguments given.\n\nloguser -info|0|1\nBy  default, the send/expect dialogue is logged to stdout (and a logfile if open).  The\nlogging to stdout is disabled by the command \"loguser 0\" and  reenabled  by  \"loguser\n1\".  Logging to the logfile is unchanged.\n\nThe  -info flag causes loguser to return a description of the most recent non-info ar‐\nguments given.\n\nmatchmax [-d] [-i spawnid] [size]\ndefines the size of the buffer (in bytes) used internally by expect.  With no size  ar‐\ngument, the current size is returned.\n\nWith the -d flag, the default size is set.  (The initial default is 2000.)  With the -i\nflag, the size is set for the named spawn id, otherwise  it  is  set  for  the  current\nprocess.\n\noverlay [-# spawnid] [-# spawnid] [...] program [args]\nexecutes program args in place of the current Expect program, which terminates.  A bare\nhyphen argument forces a hyphen in front of the command name  as  if  it  was  a  login\nshell.  All spawnids are closed except for those named as arguments.  These are mapped\nonto the named file identifiers.\n\nSpawnids are mapped to file identifiers for the new program to inherit.  For  example,\nthe  following  line runs chess and allows it to be controlled by the current process -\nsay, a chess master.\n\noverlay -0 $spawnid -1 $spawnid -2 $spawnid chess\n\nThis is more efficient than \"interact -u\", however, it sacrifices  the  ability  to  do\nprogrammed interaction since the Expect process is no longer in control.\n\nNote  that no controlling terminal is provided.  Thus, if you disconnect or remap stan‐\ndard input, programs that do job control (shells, login, etc) will not  function  prop‐\nerly.\n\nparity [-d] [-i spawnid] [value]\ndefines  whether  parity should be retained or stripped from the output of spawned pro‐\ncesses.  If value is zero, parity is stripped, otherwise it is not stripped.   With  no\nvalue argument, the current value is returned.\n\nWith  the  -d  flag, the default parity value is set.  (The initial default is 1, i.e.,\nparity is not stripped.)  With the -i flag, the parity value is set for the named spawn\nid, otherwise it is set for the current process.\n\nremovenulls [-d] [-i spawnid] [value]\ndefines  whether nulls are retained or removed from the output of spawned processes be‐\nfore pattern matching or storing in the variable expectout or interactout.  If  value\nis  1,  nulls  are removed.  If value is 0, nulls are not removed.  With no value argu‐\nment, the current value is returned.\n\nWith the -d flag, the default value is set.  (The initial default is 1, i.e., nulls are\nremoved.)   With  the -i flag, the value is set for the named spawn id, otherwise it is\nset for the current process.\n\nWhether or not nulls are removed, Expect will record null bytes to the log and stdout.\n\nsend [-flags] string\nSends string to the current process.  For example, the command\n\nsend \"hello world\\r\"\n\nsends the characters, h e l l o <blank> w o r l d  <return>  to  the  current  process.\n(Tcl includes a printf-like command (called format) which can build arbitrarily complex\nstrings.)\n\nCharacters are sent immediately although programs with  line-buffered  input  will  not\nread  the  characters  until a return character is sent.  A return character is denoted\n\"\\r\".\n\nThe -- flag forces the next argument to be interpreted as a string rather than a  flag.\nAny  string can be preceded by \"--\" whether or not it actually looks like a flag.  This\nprovides a reliable mechanism to specify variable strings without being tripped  up  by\nthose  that  accidentally look like flags.  (All strings starting with \"-\" are reserved\nfor future options.)\n\nThe -i flag declares that the string be sent to the named spawnid.  If the spawnid is\nuserspawnid,  and  the terminal is in raw mode, newlines in the string are translated\nto return-newline sequences so that they appear as if the terminal was in cooked  mode.\nThe -raw flag disables this translation.\n\nThe  -null flag sends null characters (0 bytes).  By default, one null is sent.  An in‐\nteger may follow the -null to indicate how many nulls to send.\n\nThe -break flag generates a break condition.  This only makes sense  if  the  spawn  id\nrefers to a tty device opened via \"spawn -open\".  If you have spawned a process such as\ntip, you should use tip's convention for generating a break.\n\nThe -s flag forces output to be sent \"slowly\", thus avoid the common situation where  a\ncomputer outtypes an input buffer that was designed for a human who would never outtype\nthe same buffer.  This output is controlled by the value of  the  variable  \"sendslow\"\nwhich  takes  a  two  element list.  The first element is an integer that describes the\nnumber of bytes to send atomically.  The second element is a real number that describes\nthe  number  of seconds by which the atomic sends must be separated.  For example, \"set\nsendslow {10 .001}\" would force \"send -s\" to send strings with 1  millisecond  in  be‐\ntween each 10 characters sent.\n\nThe  -h  flag forces output to be sent (somewhat) like a human actually typing.  Human-\nlike delays appear between the characters.  (The algorithm is based upon a Weibull dis‐\ntribution,  with  modifications  to  suit this particular application.)  This output is\ncontrolled by the value of the variable \"sendhuman\" which takes a five  element  list.\nThe  first  two  elements  are average interarrival time of characters in seconds.  The\nfirst is used by default.  The second is used at word endings, to simulate  the  subtle\npauses  that  occasionally occur at such transitions.  The third parameter is a measure\nof variability where .1 is quite variable, 1 is reasonably variable, and  10  is  quite\ninvariable.   The  extremes  are  0  to infinity.  The last two parameters are, respec‐\ntively, a minimum and maximum interarrival time.  The minimum and maximum are used last\nand  \"clip\" the final time.  The ultimate average can be quite different from the given\naverage if the minimum and maximum clip enough values.\n\nAs an example, the following command emulates a fast and consistent typist:\n\nset sendhuman {.1 .3 1 .05 2}\nsend -h \"I'm hungry.  Let's do lunch.\"\n\nwhile the following might be more suitable after a hangover:\n\nset sendhuman {.4 .4 .2 .5 100}\nsend -h \"Goodd party lash night!\"\n\nNote that errors are not simulated, although you can set up error correction situations\nyourself by embedding mistakes and corrections in a send argument.\n\nThe  flags for sending null characters, for sending breaks, for forcing slow output and\nfor human-style output are mutually exclusive. Only the  one  specified  last  will  be\nused.  Furthermore, no string argument can be specified with the flags for sending null\ncharacters or breaks.\n\nIt is a good idea to precede the first send to a process by  an  expect.   expect  will\nwait  for  the  process  to start, while send cannot.  In particular, if the first send\ncompletes before the process starts running, you run the risk of having your  data  ig‐\nnored.   In situations where interactive programs offer no initial prompt, you can pre‐\ncede send by a delay as in:\n\n# To avoid giving hackers hints on how to break in,\n# this system does not prompt for an external password.\n# Wait for 5 seconds for exec to complete\nspawn telnet very.secure.gov\nsleep 5\nsend password\\r\n\nexpsend is an alias for send.  If you are using Expectk or some other variant  of  Ex‐\npect  in  the  Tk environment, send is defined by Tk for an entirely different purpose.\nexpsend is provided for compatibility between environments.  Similar aliases are  pro‐\nvided for other Expect's other send commands.\n\nsenderror [-flags] string\nis like send, except that the output is sent to stderr rather than the current process.\n\nsendlog [--] string\nis  like send, except that the string is only sent to the log file (see logfile.)  The\narguments are ignored if no log file is open.\n\nsendtty [-flags] string\nis like send, except that the output is  sent  to  /dev/tty  rather  than  the  current\nprocess.\n\nsenduser [-flags] string\nis like send, except that the output is sent to stdout rather than the current process.\n\nsleep seconds\ncauses  the  script to sleep for the given number of seconds.  Seconds may be a decimal\nnumber.  Interrupts (and Tk events if you are using Expectk) are processed while Expect\nsleeps.\n\nspawn [args] program [args]\ncreates a new process running program args.  Its stdin, stdout and stderr are connected\nto Expect, so that they may be read and written by other Expect commands.  The  connec‐\ntion is broken by close or if the process itself closes any of the file identifiers.\n\nWhen a process is started by spawn, the variable spawnid is set to a descriptor refer‐\nring to that process.  The process described by  spawnid  is  considered  the  current\nprocess.  spawnid may be read or written, in effect providing job control.\n\nuserspawnid  is  a  global variable containing a descriptor which refers to the user.\nFor example, when spawnid is set to this value, expect behaves like expectuser.\n\nerrorspawnid is a global variable containing a descriptor which refers to  the  stan‐\ndard  error.   For  example,  when  spawnid  is  set  to this value, send behaves like\nsenderror.\n\nttyspawnid is a global variable containing a descriptor which refers to /dev/tty.  If\n/dev/tty  does not exist (such as in a cron, at, or batch script), then ttyspawnid is\nnot defined.  This may be tested as:\n\nif {[info vars ttyspawnid]} {\n# /dev/tty exists\n} else {\n# /dev/tty doesn't exist\n# probably in cron, batch, or at script\n}\n\n\nspawn returns the UNIX process id.  If no process is spawned, 0 is returned.  The vari‐\nable spawnout(slave,name) is set to the name of the pty slave device.\n\nBy  default, spawn echoes the command name and arguments.  The -noecho flag stops spawn\nfrom doing this.\n\nThe -console flag causes console output to be redirected to the spawned process.   This\nis not supported on all systems.\n\nInternally, spawn uses a pty, initialized the same way as the user's tty.  This is fur‐\nther initialized so that all settings are \"sane\" (according to stty(1)).  If the  vari‐\nable  sttyinit is defined, it is interpreted in the style of stty arguments as further\nconfiguration.  For example, \"set sttyinit raw\" will cause further spawned processes's\nterminals  to  start  in  raw  mode.   -nottycopy skips the initialization based on the\nuser's tty.  -nottyinit skips the \"sane\" initialization.\n\nNormally, spawn takes little time to execute.  If you notice spawn taking a significant\namount  of  time,  it is probably encountering ptys that are wedged.  A number of tests\nare run on ptys to avoid entanglements with errant processes.  (These take  10  seconds\nper wedged pty.)  Running Expect with the -d option will show if Expect is encountering\nmany ptys in odd states.  If you cannot kill the processes to which these ptys are  at‐\ntached, your only recourse may be to reboot.\n\nIf  program  cannot  be  spawned  successfully because exec(2) fails (e.g. when program\ndoesn't exist), an error message will be returned by the next interact or  expect  com‐\nmand  as if program had run and produced the error message as output.  This behavior is\na natural consequence of the implementation of spawn.  Internally, spawn  forks,  after\nwhich  the  spawned  process has no way to communicate with the original Expect process\nexcept by communication via the spawnid.\n\nThe -open flag causes the next argument to be interpreted  as  a  Tcl  file  identifier\n(i.e.,  returned  by  open.)   The  spawn  id  can then be used as if it were a spawned\nprocess.  (The file identifier should no longer be used.)  This lets you treat raw  de‐\nvices, files, and pipelines as spawned processes without using a pty.  0 is returned to\nindicate there is no associated process.  When the connection to the spawned process is\nclosed,  so is the Tcl file identifier.  The -leaveopen flag is similar to -open except\nthat -leaveopen causes the file identifier to be left open even after the spawn  id  is\nclosed.\n\nThe -pty flag causes a pty to be opened but no process spawned.  0 is returned to indi‐\ncate there is no associated process.  Spawnid is set as usual.\n\nThe variable spawnout(slave,fd) is set to a file identifier corresponding to  the  pty\nslave.  It can be closed using \"close -slave\".\n\nThe  -ignore flag names a signal to be ignored in the spawned process.  Otherwise, sig‐\nnals get the default behavior.  Signals are named as in the trap command,  except  that\neach signal requires a separate flag.\n\nstrace level\ncauses  following statements to be printed before being executed.  (Tcl's trace command\ntraces variables.)  level indicates how far down in the call stack to trace.  For exam‐\nple,  the  following command runs Expect while tracing the first 4 levels of calls, but\nnone below that.\n\nexpect -c \"strace 4\" script.exp\n\n\nThe -info flag causes strace to return a description of the most recent non-info  argu‐\nments given.\n\nstty args\nchanges terminal modes similarly to the external stty command.\n\nBy  default,  the controlling terminal is accessed.  Other terminals can be accessed by\nappending \"< /dev/tty...\" to the command.  (Note  that  the  arguments  should  not  be\ngrouped into a single argument.)\n\nRequests  for status return it as the result of the command.  If no status is requested\nand the controlling terminal is accessed, the previous status of the raw and  echo  at‐\ntributes are returned in a form which can later be used by the command.\n\nFor  example,  the  arguments raw or -cooked put the terminal into raw mode.  The argu‐\nments -raw or cooked put the terminal into cooked mode.  The arguments echo  and  -echo\nput the terminal into echo and noecho mode respectively.\n\nThe  following  example  illustrates how to temporarily disable echoing.  This could be\nused in otherwise-automatic scripts to avoid embedding passwords in  them.   (See  more\ndiscussion on this under EXPECT HINTS below.)\n\nstty -echo\nsenduser \"Password: \"\nexpectuser -re \"(.*)\\n\"\nset password $expectout(1,string)\nstty echo\n\n\nsystem args\ngives  args  to sh(1) as input, just as if it had been typed as a command from a termi‐\nnal.  Expect waits until the shell terminates.  The return status from  sh  is  handled\nthe same way that exec handles its return status.\n\nIn  contrast to exec which redirects stdin and stdout to the script, system performs no\nredirection (other than that indicated by the string itself).  Thus, it is possible  to\nuse programs which must talk directly to /dev/tty.  For the same reason, the results of\nsystem are not recorded in the log.\n\ntimestamp [args]\nreturns a timestamp.  With no arguments, the number of seconds since the epoch  is  re‐\nturned.\n\nThe  -format flag introduces a string which is returned but with substitutions made ac‐\ncording to the POSIX rules for strftime.  For example %a is replaced by an  abbreviated\nweekday name (i.e., Sat).  Others are:\n%a      abbreviated weekday name\n%A      full weekday name\n%b      abbreviated month name\n%B      full month name\n%c      date-time as in: Wed Oct  6 11:45:56 1993\n%d      day of the month (01-31)\n%H      hour (00-23)\n%I      hour (01-12)\n%j      day (001-366)\n%m      month (01-12)\n%M      minute (00-59)\n%p      am or pm\n%S      second (00-61)\n%u      day (1-7, Monday is first day of week)\n%U      week (00-53, first Sunday is first day of week one)\n%V      week (01-53, ISO 8601 style)\n%w      day (0-6)\n%W      week (00-53, first Monday is first day of week one)\n%x      date-time as in: Wed Oct  6 1993\n%X      time as in: 23:59:59\n%y      year (00-99)\n%Y      year as in: 1993\n%Z      timezone (or nothing if not determinable)\n%%      a bare percent sign\n\nOther  %  specifications  are  undefined.   Other characters will be passed through un‐\ntouched.  Only the C locale is supported.\n\nThe -seconds flag introduces a number of seconds since the epoch to be used as a source\nfrom which to format.  Otherwise, the current time is used.\n\nThe -gmt flag forces timestamp output to use the GMT timezone.  With no flag, the local\ntimezone is used.\n\ntrap [[command] signals]\ncauses the given command to be executed upon future receipt of any of  the  given  sig‐\nnals.   The  command is executed in the global scope.  If command is absent, the signal\naction is returned.  If command is the string SIGIGN, the  signals  are  ignored.   If\ncommand  is  the string SIGDFL, the signals are result to the system default.  signals\nis either a single signal or a list of signals.  Signals may be  specified  numerically\nor symbolically as per signal(3).  The \"SIG\" prefix may be omitted.\n\nWith no arguments (or the argument -number), trap returns the signal number of the trap\ncommand currently being executed.\n\nThe -code flag uses the return code of the command in place of whatever  code  Tcl  was\nabout to return when the command originally started running.\n\nThe -interp flag causes the command to be evaluated using the interpreter active at the\ntime the command started running rather than when the trap was declared.\n\nThe -name flag causes the trap command to return the signal name of  the  trap  command\ncurrently being executed.\n\nThe  -max  flag causes the trap command to return the largest signal number that can be\nset.\n\nFor example, the command \"trap {senduser \"Ouch!\"} SIGINT\"  will  print  \"Ouch!\"   each\ntime the user presses ^C.\n\nBy  default,  SIGINT  (which can usually be generated by pressing ^C) and SIGTERM cause\nExpect to exit.  This is due to the following trap,  created  by  default  when  Expect\nstarts.\n\ntrap exit {SIGINT SIGTERM}\n\nIf you use the -D flag to start the debugger, SIGINT is redefined to start the interac‐\ntive debugger.  This is due to the following trap:\n\ntrap {expdebug 1} SIGINT\n\nThe debugger trap can be changed by setting the environment variable  EXPECTDEBUGINIT\nto a new trap command.\n\nYou can, of course, override both of these just by adding trap commands to your script.\nIn particular, if you have your own \"trap exit SIGINT\", this will override the debugger\ntrap.  This is useful if you want to prevent users from getting to the debugger at all.\n\nIf you want to define your own trap on SIGINT but still trap to the debugger when it is\nrunning, use:\n\nif {![expdebug]} {trap mystuff SIGINT}\n\nAlternatively, you can trap to the debugger using some other signal.\n\ntrap will not let you override the action for SIGALRM as this is used internally to Ex‐‐\npect.   The disconnect command sets SIGALRM to SIGIGN (ignore).  You can reenable this\nas long as you disable it during subsequent spawn commands.\n\nSee signal(3) for more info.\n\nwait [args]\ndelays until a spawned process (or the current process if none is named) terminates.\n\nwait normally returns a list of four integers.  The first integer is  the  pid  of  the\nprocess  that  was waited upon.  The second integer is the corresponding spawn id.  The\nthird integer is -1 if an operating system error occurred,  or  0  otherwise.   If  the\nthird  integer was 0, the fourth integer is the status returned by the spawned process.\nIf the third integer was -1, the fourth integer is the value of errno set by the  oper‐\nating system.  The global variable errorCode is also set.\n\nAdditional  elements  may appear at the end of the return value from wait.  An optional\nfifth element identifies a class of information.  Currently, the  only  possible  value\nfor  this element is CHILDKILLED in which case the next two values are the C-style sig‐\nnal name and a short textual description.\n\nThe -i flag declares the process to wait corresponding to the named spawnid  (NOT  the\nprocess  id).  Inside a SIGCHLD handler, it is possible to wait for any spawned process\nby using the spawn id -1.\n\nThe -nowait flag causes the wait to return immediately with the indication  of  a  suc‐\ncessful  wait.  When the process exits (later), it will automatically disappear without\nthe need for an explicit wait.\n\nThe wait command may also be used wait for a forked process  using  the  arguments  \"-i\n-1\".   Unlike its use with spawned processes, this command can be executed at any time.\nThere is no control over which process is reaped.  However, the  return  value  can  be\nchecked for the process id.\n\n### LIBRARIES\n\nExpect  automatically  knows  about two built-in libraries for Expect scripts.  These are de‐\nfined by the directories named in the variables explibrary and expexeclibrary.   Both  are\nmeant to contain utility files that can be used by other scripts.\n\nexplibrary contains architecture-independent files.  expexeclibrary contains architecture-\ndependent files.  Depending on your system, both directories may be totally empty.  The exis‐\ntence  of  the  file $expexeclibrary/cat-buffers describes whether your /bin/cat buffers by\ndefault.\n\n### PRETTY-PRINTING\n\nA vgrind definition is available for pretty-printing Expect  scripts.   Assuming  the  vgrind\ndefinition supplied with the Expect distribution is correctly installed, you can use it as:\n\nvgrind -lexpect file\n\n### EXAMPLES\n\nIt  many  not  be apparent how to put everything together that the man page describes.  I en‐\ncourage you to read and try out the examples in the example directory of the Expect distribu‐\ntion.  Some of them are real programs.  Others are simply illustrative of certain techniques,\nand of course, a couple are just quick hacks.  The INSTALL file has a quick overview of these\nprograms.\n\nThe Expect papers (see SEE ALSO) are also useful.  While some papers use syntax corresponding\nto earlier versions of Expect, the accompanying rationales are still valid and go into a  lot\nmore detail than this man page.\n\n### CAVEATS\n\nExtensions  may  collide with Expect's command names.  For example, send is defined by Tk for\nan entirely different purpose.  For this reason, most of the Expect commands are also  avail‐\nable  as  \"expXXXX\".   Commands  and  variables  beginning with \"exp\", \"inter\", \"spawn\", and\n\"timeout\" do not have aliases.  Use the extended command names if you need this compatibility\nbetween environments.\n\nExpect  takes  a  rather  liberal view of scoping.  In particular, variables read by commands\nspecific to the Expect program will be sought first from the local scope, and if  not  found,\nin  the global scope.  For example, this obviates the need to place \"global timeout\" in every\nprocedure you write that uses expect.  On the other hand, variables written are always in the\nlocal scope (unless a \"global\" command has been issued).  The most common problem this causes\nis when spawn is executed in a procedure.  Outside the procedure, spawnid no longer  exists,\nso  the  spawned  process  is  no longer accessible simply because of scoping.  Add a \"global\nspawnid\" to such a procedure.\n\nIf you cannot enable the multispawning capability (i.e., your system supports neither  select\n(BSD  *.*),  poll  (SVR>2),  nor something equivalent), Expect will only be able to control a\nsingle process at a time.  In this case, do not attempt to set spawnid, nor should you  exe‐\ncute  processes  via  exec  while a spawned process is running.  Furthermore, you will not be\nable to expect from multiple processes (including the user as one) at the same time.\n\nTerminal parameters can have a big effect on scripts.  For example, if a script is written to\nlook for echoing, it will misbehave if echoing is turned off.  For this reason, Expect forces\nsane terminal parameters by default.  Unfortunately, this  can  make  things  unpleasant  for\nother  programs.   As  an example, the emacs shell wants to change the \"usual\" mappings: new‐\nlines get mapped to newlines instead of carriage-return newlines, and  echoing  is  disabled.\nThis  allows  one to use emacs to edit the input line.  Unfortunately, Expect cannot possibly\nguess this.\n\nYou can request that Expect not override its default setting of terminal parameters, but  you\nmust  then be very careful when writing scripts for such environments.  In the case of emacs,\navoid depending upon things like echoing and end-of-line mappings.\n\nThe commands that accepted arguments braced into a single list (the expect variants  and  in‐‐\nteract)  use a heuristic to decide if the list is actually one argument or many.  The heuris‐\ntic can fail only in the case when the list actually does represent a single  argument  which\nhas  multiple  embedded  \\n's with non-whitespace characters between them.  This seems suffi‐\nciently improbable, however the argument \"-nobrace\" can be used to force a single argument to\nbe  handled  as a single argument.  This could conceivably be used with machine-generated Ex‐\npect code.  Similarly, -brace forces a single argument to be handle as multiple  patterns/ac‐\ntions.\n\n### BUGS\n\nIt  was really tempting to name the program \"sex\" (for either \"Smart EXec\" or \"Send-EXpect\"),\nbut good sense (or perhaps just Puritanism) prevailed.\n\nOn some systems, when a shell is spawned, it complains about not being able to access the tty\nbut runs anyway.  This means your system has a mechanism for gaining the controlling tty that\nExpect doesn't know about.  Please find out what it is, and send this information back to me.\n\nUltrix 4.1 (at least the latest versions around here) considers timeouts of above 1000000  to\nbe equivalent to 0.\n\nDigital  UNIX  4.0A  (and  probably  other versions) refuses to allocate ptys if you define a\nSIGCHLD handler.  See grantpt page for more info.\n\nIRIX 6.0 does not handle pty permissions correctly so that if Expect attempts to  allocate  a\npty previously used by someone else, it fails.  Upgrade to IRIX 6.1.\n\nTelnet  (verified  only under SunOS 4.1.2) hangs if TERM is not set.  This is a problem under\ncron, at and in cgi scripts, which do not define TERM.  Thus, you must set it explicitly - to\nwhat type is usually irrelevant.  It just has to be set to something!  The following probably\nsuffices for most cases.\n\nset env(TERM) vt100\n\n\nTip (verified only under BSDI BSD/OS 3.1 i386) hangs if SHELL and HOME are not set.  This  is\na problem under cron, at and in cgi scripts, which do not define these environment variables.\nThus, you must set them explicitly - to what type is usually irrelevant.  It just has  to  be\nset to something!  The following probably suffices for most cases.\n\nset env(SHELL) /bin/sh\nset env(HOME) /usr/bin\n\n\n\nSome  implementations  of  ptys are designed so that the kernel throws away any unread output\nafter 10 to 15 seconds (actual number is  implementation-dependent)  after  the  process  has\nclosed the file descriptor.  Thus Expect programs such as\n\nspawn date\nsleep 20\nexpect\n\nwill  fail.   To  avoid  this,  invoke  non-interactive programs with exec rather than spawn.\nWhile such situations are conceivable, in practice I have never encountered  a  situation  in\nwhich the final output of a truly interactive program would be lost due to this behavior.\n\nOn  the  other  hand,  Cray  UNICOS  ptys  throw away any unread output immediately after the\nprocess has closed the file descriptor.  I have reported this to Cray and they are working on\na fix.\n\nSometimes  a  delay is required between a prompt and a response, such as when a tty interface\nis changing UART settings or matching baud rates by looking for  start/stop  bits.   Usually,\nall this is require is to sleep for a second or two.  A more robust technique is to retry un‐\ntil the hardware is ready to receive input.  The following example uses both strategies:\n\nsend \"speed 9600\\r\";\nsleep 1\nexpect {\ntimeout {send \"\\r\"; expcontinue}\n$prompt\n}\n\n\ntrap -code will not work with any command that sits in Tcl's event loop, such as sleep.   The\nproblem  is  that in the event loop, Tcl discards the return codes from async event handlers.\nA workaround is to set a flag in the trap code.  Then check the flag  immediately  after  the\ncommand (i.e., sleep).\n\nThe  expectbackground  command  ignores -timeout arguments and has no concept of timeouts in\ngeneral.\n\n### EXPECT HINTS\n\nThere are a couple of things about Expect that may be non-intuitive.  This  section  attempts\nto address some of these things with a couple of suggestions.\n\nA  common  expect problem is how to recognize shell prompts.  Since these are customized dif‐\nferently by differently people and different shells, portably automating rlogin can be diffi‐\ncult  without  knowing  the prompt.  A reasonable convention is to have users store a regular\nexpression describing their prompt (in particular, the end of it) in the environment variable\nEXPECTPROMPT.   Code  like  the  following can be used.  If EXPECTPROMPT doesn't exist, the\ncode still has a good chance of functioning correctly.\n\nset prompt \"(%|#|\\\\$) $\"          ;# default prompt\ncatch {set prompt $env(EXPECTPROMPT)}\n\nexpect -re $prompt\n\nI encourage you to write expect patterns that include the end of whatever you expect to  see.\nThis avoids the possibility of answering a question before seeing the entire thing.  In addi‐\ntion, while you may well be able to answer questions before seeing them entirely, if you  an‐\nswer  early,   your  answer  may  appear echoed back in the middle of the question.  In other\nwords, the resulting dialogue will be correct but look scrambled.\n\nMost prompts include a space character at the end.  For example, the prompt from ftp is  'f',\n't',  'p', '>' and <blank>.  To match this prompt, you must account for each of these charac‐\nters.  It is a common mistake not to include the blank.  Put the blank in explicitly.\n\nIf you use a pattern of the form X*, the * will match all the output received from the end of\nX  to  the  last thing received.  This sounds intuitive but can be somewhat confusing because\nthe phrase \"last thing received\" can vary depending upon the speed of the  computer  and  the\nprocessing of I/O both by the kernel and the device driver.\n\nIn particular, humans tend to see program output arriving in huge chunks (atomically) when in\nreality most programs produce output one line at a time.  Assuming this is the case, the * in\nthe  pattern of the previous paragraph may only match the end of the current line even though\nthere seems to be more, because at the time of the match that was all  the  output  that  had\nbeen received.\n\nexpect  has  no way of knowing that further output is coming unless your pattern specifically\naccounts for it.\n\nEven depending on line-oriented buffering is unwise.  Not only do programs rarely make  prom‐\nises about the type of buffering they do, but system indigestion can break output lines up so\nthat lines break at seemingly random places.  Thus, if you can express the last  few  charac‐\nters of a prompt when writing patterns, it is wise to do so.\n\nIf  you are waiting for a pattern in the last output of a program and the program emits some‐\nthing else instead, you will not be able to detect that with the timeout keyword.  The reason\nis  that  expect will not timeout - instead it will get an eof indication.  Use that instead.\nEven better, use both.  That way if that line is ever moved around, you won't  have  to  edit\nthe line itself.\n\nNewlines are usually converted to carriage return, linefeed sequences when output by the ter‐\nminal driver.  Thus, if you want a pattern that explicitly matches the two lines, from,  say,\nprintf(\"foo\\nbar\"), you should use the pattern \"foo\\r\\nbar\".\n\nA similar translation occurs when reading from the user, via expectuser.  In this case, when\nyou press return, it will be translated to a newline.  If Expect then passes that to  a  pro‐\ngram  which  sets  its terminal to raw mode (like telnet), there is going to be a problem, as\nthe program expects a true return.  (Some programs are actually forgiving in that  they  will\nautomatically translate newlines to returns, but most don't.)  Unfortunately, there is no way\nto find out that a program put its terminal into raw mode.\n\nRather than manually replacing newlines with returns, the solution  is  to  use  the  command\n\"stty raw\", which will stop the translation.  Note, however, that this means that you will no\nlonger get the cooked line-editing features.\n\ninteract implicitly sets your terminal to raw mode so this problem will not arise then.\n\nIt is often useful to store passwords (or other private information) in Expect scripts.  This\nis  not  recommended  since anything that is stored on a computer is susceptible to being ac‐\ncessed by anyone.  Thus, interactively prompting for passwords from a  script  is  a  smarter\nidea than embedding them literally.  Nonetheless, sometimes such embedding is the only possi‐\nbility.\n\nUnfortunately, the UNIX file system has no direct way of  creating  scripts  which  are  exe‐\ncutable  but  unreadable.  Systems which support setgid shell scripts may indirectly simulate\nthis as follows:\n\nCreate the Expect script (that contains the secret data) as usual.  Make its  permissions  be\n750 (-rwxr-x---) and owned by a trusted group, i.e., a group which is allowed to read it.  If\nnecessary, create a new group for this purpose.  Next, create a /bin/sh script  with  permis‐\nsions 2751 (-rwxr-s--x) owned by the same group as before.\n\nThe result is a script which may be executed (and read) by anyone.  When invoked, it runs the\nExpect script.\n\n### SEE ALSO\n\nTcl(3), libexpect(3)\n\"Exploring Expect: A Tcl-Based Toolkit for Automating Interactive Programs\" by Don Libes, pp.\n602, ISBN 1-56592-090-2, O'Reilly and Associates, 1995.\n\"expect:  Curing Those Uncontrollable Fits of Interactivity\" by Don Libes, Proceedings of the\nSummer 1990 USENIX Conference, Anaheim, California, June 11-15, 1990.\n\"Using expect to Automate System Administration Tasks\" by Don Libes, Proceedings of the  1990\nUSENIX  Large Installation Systems Administration Conference, Colorado Springs, Colorado, Oc‐\ntober 17-19, 1990.\n\"Tcl: An Embeddable Command Language\" by John Ousterhout,  Proceedings  of  the  Winter  1990\nUSENIX Conference, Washington, D.C., January 22-26, 1990.\n\"expect:  Scripts for Controlling Interactive Programs\" by Don Libes, Computing Systems, Vol.\n4, No. 2, University of California Press Journals, November 1991.\n\"Regression Testing and Conformance Testing Interactive Programs\", by Don Libes,  Proceedings\nof the Summer 1992 USENIX Conference, pp. 135-144, San Antonio, TX, June 12-15, 1992.\n\"Kibitz  - Connecting Multiple Interactive Programs Together\", by Don Libes, Software - Prac‐\ntice & Experience, John Wiley & Sons, West Sussex, England, Vol. 23, No. 5, May, 1993.\n\"A Debugger for Tcl Applications\", by Don Libes, Proceedings of  the  1993  Tcl/Tk  Workshop,\nBerkeley, CA, June 10-11, 1993.\n\n### AUTHOR\n\nDon Libes, National Institute of Standards and Technology\n\n### ACKNOWLEDGMENTS\n\nThanks  to  John Ousterhout for Tcl, and Scott Paisley for inspiration.  Thanks to Rob Savoye\nfor Expect's autoconfiguration code.\n\nThe HISTORY file documents much of the evolution of expect.  It makes interesting reading and\nmight  give  you  further insight to this software.  Thanks to the people mentioned in it who\nsent me bug fixes and gave other assistance.\n\nDesign and implementation of Expect was paid for in part by the U.S. government and is there‐\nfore in the public domain.  However the author and NIST would like credit if this program and\ndocumentation or portions of them are used.\n\n\n\n29 December 1994                                 EXPECT(1)\n\n"
        }
    ],
    "structuredContent": {
        "command": "EXPECT",
        "section": "1",
        "mode": "man",
        "summary": "expect - programmed dialogue with interactive programs, Version 5",
        "synopsis": "expect [ -dDinN ] [ -c cmds ] [ [ -[f|b] ] cmdfile ] [ args ]",
        "flags": [
            {
                "flag": "-v",
                "long": null,
                "arg": null,
                "description": "which uses long flag names, is -version.) Optional args are constructed into a list and stored in the variable named argv. argc is initialized to the length of argv. argv0 is defined to be the name of the script (or binary if no script is used). For example, the following prints out the name of the script and the first three arguments: senduser \"$argv0 [lrange $argv 0 2]\\n\""
            }
        ],
        "examples": [
            "It  many  not  be apparent how to put everything together that the man page describes.  I en‐",
            "courage you to read and try out the examples in the example directory of the Expect distribu‐",
            "tion.  Some of them are real programs.  Others are simply illustrative of certain techniques,",
            "and of course, a couple are just quick hacks.  The INSTALL file has a quick overview of these",
            "programs.",
            "The Expect papers (see SEE ALSO) are also useful.  While some papers use syntax corresponding",
            "to earlier versions of Expect, the accompanying rationales are still valid and go into a  lot",
            "more detail than this man page."
        ],
        "see_also": [
            {
                "name": "Tcl",
                "section": "3",
                "url": "https://www.chedong.com/phpMan.php/man/Tcl/3/json"
            },
            {
                "name": "libexpect",
                "section": "3",
                "url": "https://www.chedong.com/phpMan.php/man/libexpect/3/json"
            }
        ],
        "section_outline": [
            {
                "name": "NAME",
                "lines": 2,
                "subsections": []
            },
            {
                "name": "SYNOPSIS",
                "lines": 2,
                "subsections": []
            },
            {
                "name": "INTRODUCTION",
                "lines": 41,
                "subsections": []
            },
            {
                "name": "USAGE",
                "lines": 62,
                "subsections": [
                    {
                        "name": "-v",
                        "lines": 11,
                        "flag": "-v"
                    }
                ]
            },
            {
                "name": "COMMANDS",
                "lines": 55,
                "subsections": [
                    {
                        "name": "disconnect",
                        "lines": 611
                    },
                    {
                        "name": "interpreter  [args]",
                        "lines": 455
                    }
                ]
            },
            {
                "name": "LIBRARIES",
                "lines": 9,
                "subsections": []
            },
            {
                "name": "PRETTY-PRINTING",
                "lines": 6,
                "subsections": []
            },
            {
                "name": "EXAMPLES",
                "lines": 10,
                "subsections": []
            },
            {
                "name": "CAVEATS",
                "lines": 43,
                "subsections": []
            },
            {
                "name": "BUGS",
                "lines": 72,
                "subsections": []
            },
            {
                "name": "EXPECT HINTS",
                "lines": 85,
                "subsections": []
            },
            {
                "name": "SEE ALSO",
                "lines": 19,
                "subsections": []
            },
            {
                "name": "AUTHOR",
                "lines": 2,
                "subsections": []
            },
            {
                "name": "ACKNOWLEDGMENTS",
                "lines": 14,
                "subsections": []
            }
        ]
    }
}