The send_tty Command
send_tty
is analogous to expect_tty
. The send_tty
command sends its output to the screen in such a way that it cannot be redirected by the shell. send_tty
shares the very same advantages and disadvantages of expect_tty
.
expect_tty
and send_tty
work by communicating through a special file called /dev/tty
. Expect is one of a few programs that has the power to redirect communications with programs that communicate through /dev/tty
. When programs are spawned by Expect, all of their inputs (/dev/tty
and unredirected standard input) are merged into a single input to which the send
command can write. Similarly, all of their outputs (/dev/tty
and any unredirected standard output or standard error) are merged into a single output from which the expect
command can read.
Thus, Expect reads and writes from processes with the same view that a real person has. In the same way a person can read all of the unredirected output or write all of the unredirected input, so can Expect. If a human can control a program, then the program can be controlled with Expect also. This is the power of Expect.
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.