Differences Between Expect And The Expect Extension In Another Program

When using tclsh or any other program to which you have added Exp_Init, you may encounter differences between it and Expect.

  • Command-Line Argument Handling

    Expect defines the behavior of the command-line flags such as -c and -d. Any other program is not likely to support these. tclsh supports only the -f flag. Most Tcl programs make other arguments available to the script using the argv and argc variables as Expect does.

  • Signal Handling

    It is possible for other extensions to try and handle signals at the same time that Expect does. However, only one extension can handle the same signal at a time. Multiple extensions may claim to be handling the signal but only one of the signal handlers will be called. Signal definitions should be under control of the user so this should not be a problem.

    The default signal handlers that Expect uses (i.e., SIGINT, SIGTERM) are not automatically established by tclsh.

  • Command Names

    Expect commands that share the same names as commands in another extension are usually suppressed (unless the other extension also suppresses its own definition). For example, if another extension defines "spawn“, it overrides Expect’s spawn.

    To guarantee that you get Expect’s commands, preface them with "exp_“. For example, when using Tk, "send" is Tk’s while "exp_send" is Expect’s. The "exp_" versions are always available, even when not using any other extensions, so you can use them all the time if you do ...

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

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