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 gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Expect - handling multiple processes simultaneously

Status
Not open for further replies.

ExpectTheUnexpected

Programmer
Jun 17, 2010
22
US
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
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top