ActiveState Community

Windows expect /Unix expect

Posted by dave_mairs on 2008-01-14 04:46

I am using ActiveState 8.4.16.0, I have found this code format that seems to work great:

expect "Login:*"
send "root\r"
expect ">*"
send "ksh\r"
expect "#*"
send "tar -xvf /dev/rmt/0m\r"
expect "#"

My question is, how do I set it up to fail out if one of the expect calls
doesn't happen? In UX it would be aomething like:

proc T1 {} {
set EXITCODE [format "NO root prompt\n" ]
send_user $EXITCODE
exit -1
}

set timeout 5

expect {#*} {send "root\r"} \
timeout {T1}

If "#" wasn't found in 5 seconds, the program would fail and the log would report "NO root prompt"

jeffh | Mon, 2008-01-14 11:32

Have you tried the same in Windows Expect? It supports the timeout functionality. The docs list the specific differences between the versions.

dave_mairs | Mon, 2008-01-14 12:44

The hyerlink for doc above, is not working for me? Could you send along the URL?

Thanks

jeffh | Mon, 2008-01-14 12:49

It is part of the documentation that comes with ActiveTcl on Windows.

?
pmcd | Fri, 2008-04-11 16:23

?