How do I embed an expect script that takes in arguments into a bash shell script?

Posted by fzkl on Stack Overflow See other posts from Stack Overflow or by fzkl
Published on 2010-12-30T14:17:25Z Indexed on 2010/12/30 14:54 UTC
Read the original article Hit count: 439

Filed under:
|
|
|
|

I am writing a bash script which amongst many other things uses expect to automatically run a binary and install it by answering installer prompts.

I was able to get my expect script to work fine when the expect script is called in my bash script with the command "expect $expectscriptname $Parameter". However, I want to embed the expect script into the shell script instead of having to maintain two separate script files for the job. I searched around and found that the procedure to embed expect into bash script was to declare a variable like VAR below and then echo it.:

VAR=$(expect -c "
#content of expect script here
")
echo "$VAR"

1) I don't understand how echoing $VAR actually runs the expect script. Could anyone explain?
2) I am not sure how to pass $Parameter into VAR or to the echo statement. This is my main concern.

Any ideas? Thanks.

© Stack Overflow or respective owner

Related posts about bash

Related posts about shell