Chapter 16. Interacting With Multiple Processes
The previous chapter had numerous examples, all showing how to create a connection between a user and the currently spawned process. The interact
command does this by default, but it is possible to create connections in other ways. In this chapter, I will cover how to use the interact
command with a process other than the user and currently spawned process, or with multiple processes.
Connecting To A Process Other Than The Currently Spawned Process
Like many of the other commands in Expect, the interact
command accepts the −i
flag to indicate a spawn id to be used in place of the currently spawned process. For example:
spawn telnet set telnet $spawn_id spawn ftp interact −i $telnet
In this example, interact
connects the user to the telnet
process. Without the "-i $telnet
“, the ftp
process is connected.
Output from the process is tested against any patterns appearing after the −i
flag. In other words, the −i
behaves as if a -o
flag had also appeared.
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.