December 1994
Intermediate to advanced
606 pages
16h 7m
English
The expect command always sets expect_out(spawn_id) to the spawn id associated with the matching output. This allows a single action parameterized on its spawn id to be shared between a number of spawn ids. For efficiency reasons, the interact command does not automatically do a similar assignment. Instead, the -iwrite flag controls whether the spawn id is recorded, in this case, to interact_out(spawn_id).
The -iwrite flag should appear before each pattern to which it applies. For example, in the following fragment, action1 and action3 can access the value of interact_out(spawn_id) but action2 cannot.
interact {
-input "$user_spawn_id $userin"
-iwrite "foo" {action1}
"bar" {action2}
-iwrite "baz" {action3}
}See Chapter 11 (p. 249) for more examples of the spawn_id element.