Assume the following bash
script, questions.sh
:
#!/bin/bash
echo "Hello, who are you?"
read REPLY
and the following expect
script:
#!/usr/bin/expect -f
spawn ./questions.sh # start our script using spawn command
expect "Hello, who are you?\r"
send -- "Im Adam\r"
The expect script acts as an answering robot to the shell script. Now assume that that I need to generate some answers dynamically. For instance, let's say that I want to feed the output of another shell script (answers.sh
) as an answer. How would I have to modify the expect
script? I tried the following but does not seem to work:
#!/usr/bin/expect -f
spawn ./questions.sh # start our script using spawn command
expect "Hello, who are you?\r"
send ./answers.sh
./answers.sh | ./questions.sh