ExpectTheUnexpected
Programmer
Hello,
I am learning Expect and having difficulty with handling multiple processes simultaneously. I spawn 2 processes. In pseudo code below, Process2 ends first and sends an EOF to expect block and expect returns. However, Process 1 is still running and I would like expect to process output from Process 1 and wait for its execution to end.
expect {
-i $Process1
-re "junk" { p1action1 ; exp_continue }
-re "foo1" { p1action2 ; exp_continue }
eof { exp_continue; #Process 2 may not be finished yet!}
-i $Process2
-re "123456" { p2action1 ; exp_continue }
-re "dummy" { p2action2 ; exp_continue }
eof { exp_continue; #Process 1 may not be finished yet! }
}
For example, if I run exp_continue command to handle EOF for Process2 then expect throws following error message:
"expect: spawn id exp9 not open"
exp9 is id associated with Process2 - the process that sent EOF. How can this issue be addressed?
Thanks
I am learning Expect and having difficulty with handling multiple processes simultaneously. I spawn 2 processes. In pseudo code below, Process2 ends first and sends an EOF to expect block and expect returns. However, Process 1 is still running and I would like expect to process output from Process 1 and wait for its execution to end.
expect {
-i $Process1
-re "junk" { p1action1 ; exp_continue }
-re "foo1" { p1action2 ; exp_continue }
eof { exp_continue; #Process 2 may not be finished yet!}
-i $Process2
-re "123456" { p2action1 ; exp_continue }
-re "dummy" { p2action2 ; exp_continue }
eof { exp_continue; #Process 1 may not be finished yet! }
}
For example, if I run exp_continue command to handle EOF for Process2 then expect throws following error message:
"expect: spawn id exp9 not open"
exp9 is id associated with Process2 - the process that sent EOF. How can this issue be addressed?
Thanks