Sunday, 15 August 2010

waiting for multiple processes to finish with expect -



waiting for multiple processes to finish with expect -

am looking build in expect watch output multiple jobs , not finish until have returned expected output or have timed out.

read indirect spawn ids. works now.

#!/usr/bin/env expect spawn echo 0 passed set list $spawn_id spawn echo 1 passed set list "$list $spawn_id" set waiting_cnt [llength $list] send_user "list '$list', length $waiting_cnt\n" set timeout 2 expect { -i list eof { set index [lsearch $list $expect_out(spawn_id)] set list [lreplace $list $index $index] if [llength $list] exp_continue } -i list -re passed { send_user "passed seen on $expect_out(spawn_id)\n" incr waiting_cnt -1 exp_continue } } send_user "both seem have passed, waiting_cnt = $waiting_cnt\n"

expect

No comments:

Post a Comment