Skip to Content
Exploring Expect
book

Exploring Expect

by Don Libes
December 1994
Intermediate to advanced
606 pages
16h 7m
English
O'Reilly Media, Inc.
Content preview from Exploring Expect

Creating Script-less Expect Programs

Expect normally uses a script to control its execution. This means that to run an Expect application, you need both an Expect interpreter and a script.

It is possible to combine the script and the interpreter together, producing a single executable that does not depend on any other files. This executable can be copied to new machines. The machines must be binary compatible and the script must make sense on the new machine. For example, programs that are spawned by the script must exist on the new machine. Stand-alone executables that run a particular script are often called compiled, although that is not the usual definition of the word.

Compiled scripts are large. Each one must contain the script plus the executable code for Expect. If you use a single Expect application on a computer, then a compiled script makes sense. If you use more than one Expect application, compiled scripts are just a waste of space. Other than space, there are no significant differences in functionality between compiled scripts and file-based scripts.

To create a compiled Expect script using the exp_main_exp.c template, replace all of the calls to the Expect interpretation phase (such as exp_interpret_cmdfilename) with a call to Tcl_Eval. As an argument to Tcl_Eval, pass the string representing the file contents.

Tcl_Eval(interp,cmdstring);

The string representation of the command must be in writeable memory. One way to guarantee this is to declare it in the following style: ...

Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Start your free trial

You might also like

AI Agents in Action

AI Agents in Action

Micheal Lanham
Learning Go

Learning Go

Jon Bodner

Publisher Resources

ISBN: 9781565920903Supplemental ContentErrata Page