Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

wait() in expect

Status
Not open for further replies.

jeans

Programmer
Apr 4, 2001
22
IL
Hi all,

I'm trying to glue a simple expect script that spawn's a process (in my case 'scp'), wait's for its completion and then exits with the exit code of the scp.

Should be very simple, but I'm not familiar with TCL's syntax. Could someone please post a source code example that does what I need?

From what I understand, it needs to be:
spawn (and get the $spawn_id)
expect (I have this covered - you may just skip this part)
wait
set scp_exit_code (this is my main problem due to lack of syntax and probably general ignorance in the tcl/expect field)
exit $scp_exit_code

...

Thanks a lot everybody!

Jean






Jean Spector
QA Team Leader @ Kashya Ltd.
 
[tt]
NAME
after - Execute a command after a time delay
SYNOPSIS
after ms
after ms ?script script script ...?
after cancel id
after cancel script script script ...
after idle ?script script script ...?
after info ?id?
DESCRIPTION
after ms
after ms ?script script script ...?
after cancel id
after cancel script script ...
after idle script ?script script ...?
after info ?id?
SEE ALSO
KEYWORDS
[/tt]

_________________
Bob Rashkin
 
Could someone please post a code example that runs *any* executable and gets the executable's exit code in the end.

For test executable I'd use a shell script that sleeps for several seconds and then returns 0 or 1...

Jean Spector
QA Team Leader @ Kashya Ltd.
 
Hi Jean --

Getting a return val was one of the things I was stuck on, so I ordered Libes' "Exploring Expect" book. Took a week to get, but was unstuck within an hour of unwrapping it.

Code:
$ expect
expect1.1> spawn false  (try also with true for good measure)
expect1.2> catch wait reason
expect1.3> lindex $reason 3

Found as part of catching SIGCHLD (which I had no idea was what I was trying to do :)

Larry
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top