0

I'm using this expect script as an answerfile to a interactive shell script:

#!/usr/bin/expect

spawn ./interactivescriptname
expect "Question 1?"
send "something\r"
expect "Question 2?"
send "yes\r"
expect "Password?"
send "somepassword\r"
interact

above works, but i want to use variables from a inputfile.

my variables files look like this:

var1="something"
var2="yes"
var3="somepassword"

Normally in bash i would use the source command, but this doesn't work in expect.

Any ideas?

1 Answer 1

0

One method would be to set TCL variables in a file (here, vars) and then source that file from the main script.

$ cat vars  
set var1 something
set var2 yes
set var3 Hunter2
$ cat script 
#!/usr/bin/env expect
source vars
puts $var3
$ chmod +x script
$ ./script 
Hunter2
$ 

It may be good to use more informative variable names than varN ...

You must log in to answer this question.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.