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.
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.
Read now
Unlock full access