#!/usr/bin/expect -f # no need for timeout 1 set timeout -1 spawn equo rescue generate expect { "*Understood*" { send "Yes\r\n" ; exp_continue } "*Really*" { send "Yes\r\n" ; exp_continue } "*Ok*" { send "Yes\r\n" ; exp_continue } "*generation complete*" { sleep 3; send "exit\r"; exit } # timeout { puts "timed out during generation"; exit 1 } } expect EOF puts $expect_out(buffer) lassign [wait] pid spawnid os_error_flag value if {$os_error_flag == 0} { puts "exit status: $value" } else { puts "errno: $value" }