user3764960
user3764960

Reputation:

Why doesn't timeout work in this expect script?

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

Answers (1)

Mridula Madhusudan
Mridula Madhusudan

Reputation: 81

Explicitly wait for a timeout error

expect {
 timeout {error "Password incorrect"; exit 1}
 eof

Upvotes: 1

Related Questions