I am not quite sure if it a good idea to create a new Thread or "reopen" this 3-year old Thread, if you think it's better to reopened it, please excuse my spam in this Forum but I have the same Problem and don't get a solution out of the information of the thread. At the Moment I had a script that looks like this:
#!/usr/bin/expect -f
set pass [lindex $argv 0]
spawn <CMD>
expect {
-re "Password: " {
send "$pass\r"
}
expect eof
catch wait result
}
exit [lindex $result 3]
but wenn I execute this Script I get the error
can't read "result": no such variable
while executing
"lindex $result 3"
invoked from within
"exit [lindex $result 3]"
(file "./call_tests.exp" line 13)
I already found out that probably the problem is that the SSH-Session is already closed when I try to read the exit code. But I started yesterday to understand the expect-command so I am a complete newbie and I would very thanks full if someone can help me out. best regards Dan