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

Default Input And Output

When the interact command is given with no arguments, it is equivalent to:

interact {
    -input $user_spawn_id -output $spawn_id
    -input $spawn_id -output $user_spawn_id
}

Besides omitting all of the arguments, it is possible to omit just some of them and still get reasonable defaults. There are defaults for the first two processes since an interaction invariably involves at least two processes.

If the first -input is omitted, user_spawn_id is used. If the first -output is omitted, spawn_id is used. If the -output after the second -input is omitted, user_spawn_id is used. These can also be affected by the -u and −i flags. For example, if the -u flag appears, the new spawn id is used in place of the first -input.

As an example, the following command establishes a connection between the user and an external process (not started by Expect). The external process provides two fifos for communication, one for input and one for output.

interact -output $out -input $in

The first input is implicit and is therefore user_spawn_id. User keystrokes are sent to out. Input from in is sent back to user_spawn_id so that the user can read it. The following figure shows the Expect process with the interact in progress.

Figure 16-2. 

The external process could be a C program, but it is also expressible as another Expect script with an interact of its own. For example, the second script ...

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