I have 2 simple scripts that I need them to automatically interact with each others using a third expect script
script1.sh
#!/bin/bash
echo "s1: started"
echo "question1"
read
echo "got ${REPLY}"
echo "question2"
read
echo "got ${REPLY}"
echo "question3"
read
echo "got ${REPLY}"
echo "s1: finished"
script2.sh
#!/bin/bash
echo "s2: started"
read
echo "got ${REPLY}"
echo "answer1"
read
echo "got ${REPLY}"
echo "answer2"
read
echo "got ${REPLY}"
echo "answer3"
echo "s2: finished"
auto_s1_s2.exp
#!/usr/bin/expect
spawn -noecho ./script1.sh
set s1ID $spawn_id
spawn -noecho ./script2.sh
set s2ID $spawn_id
expect -i $s1ID "question1" {
send_user "exp: question1\n"
send -i $s2ID "question1\r"
expect -i $s2ID "answer1" {
send_user "exp: answer1\n"
send -i $s1ID "answer1\r"
}
}
interact
The output of running ./auto_s1_s2.exp however is:
s1: started
question1
exp: question1
question1
s2: started
got question1
answer1
exp: answer1
I am expecting that s1 echoes question1 which is verify against expect $s1ID "question1" then the expect script would send question1 to s2 and expects answer1 from it then it sends answer to s1 and so on
It seems that answer1 was not received by script1
What am I doing wrong here?
