Reputation:
I have created the following script in order to automate a VPN process. The script runs the vpnc command and enters a password in order to activate the VPN:
#!/usr/bin/expect
set PASS [lindex $argv 0]
set timeout 10
spawn vpnc
expect : {send $PASS\r}
expect eof
But there's a problem: when given an incorrect password argument, I expect the script to exit after 10 seconds because of the timeout, but this does not happen. Instead the expect script is stuck because of the wrong password.
Why doesn't the timeout occur after 10 seconds?
Upvotes: 0
Views: 1835
Reputation: 81
Explicitly wait for a timeout error
expect {
timeout {error "Password incorrect"; exit 1}
eof
Upvotes: 1