Ela
Ela

Reputation: 373

When there are multiple "spawn" statements in the expect script, only the last spawn statement is executed fully

From expect script, I am calling two other shell scripts. But only the second shell script seems to get executed properly. Because the output statements of the first shell script is not seen in the screen. This is my expect script:

#!/usr/bin/expect
spawn /bin/bash test1.sh
spawn /bin/bash test2.sh
interact

Why is this happening? And what is the fix?

Upvotes: 4

Views: 4227

Answers (1)

pynexj
pynexj

Reputation: 20688

You need to wait for the first spawned process to finish:

spawn /bin/bash test1.sh
expect eof

spawn /bin/bash test2.sh
interact

Upvotes: 7

Related Questions