Q1: I'm not an expect
user, but it seems clear that spawn
runs a script in the background and makes it controllable by expect
, rather than just running without any interactivity.
Q2: The string is passed as a script to expect
. I assume, like most scripting languages, this is equivalent to saving the string to a file and running expect file
.
Q3: It looks like a test to see that myscript.sh
, when run, prints a message and responds to a user provided value by exiting without printing anything.
In other words, I expect you should be able to run this script with the same result:
#!/usr/bin/expect
spawn myscript.sh arg1 arg2 # Run `myscript.sh arg1 arg2` and return control to `expect`
expect "Please enter your value: " # Succeeds if the script prints this value
send "myval\r" # Simulate entering this value
expect eof # Succeeds if the script ends without printing anything
echo
out of anexpect
-script.exec echo testbla
works, but produces no output unfortunately.