我正在寻找一个期望从多个工作中观察输出的构造,并且直到所有工作都返回预期输出或超时时才完成。
答案 0 :(得分:0)
了解间接产卵ID。这现在有效。
#!/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 is '$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 to have passed, waiting_cnt = $waiting_cnt\n"