Expect - handling multiple processes simultaneously - TCL

This is a discussion on Expect - handling multiple processes simultaneously - TCL ; 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 ...

+ Reply to Thread
Results 1 to 3 of 3

Expect - handling multiple processes simultaneously

  1. Question Expect - handling multiple processes simultaneously

    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 for it to process output from Process 1 and wait for it 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

  2. Default Re: Expect - handling multiple processes simultaneously

    Hello all,

    I need to know how to send ctrl-I in send expect script....

    Please inform me somebody regarding this problem..

    Thanks & Regards,
    Vignesh.C

  3. Default Re: Expect - handling multiple processes simultaneously

    Sample code:

    # Does not wait for user to hit Enter after Ctrl+L
    stty raw -echo
    send_user "Enter Ctrl+L: "
    expect_user -re "\014" { puts "You hit Ctrl+L key!" }

    # Waits for user to user to hit Enter AFTER Ctrl+L has been hit
    stty -raw echo
    send_user "Enter Ctrl+L and hit Enter: "
    expect_user -re "\014" { puts "You hit Ctrl+L key!" }

    Hope this helps.

+ Reply to Thread

Similar Threads

  1. Run multiple queries simultaneously with SQL Compact 3.5???
    By Application Development in forum ADO DAO RDO RDS
    Replies: 9
    Last Post: 06-16-2008, 06:51 PM
  2. expect with forking multiple foreground processes
    By Application Development in forum TCL
    Replies: 0
    Last Post: 01-30-2008, 08:46 PM
  3. Threaded Perl Processes Going to Sleep Simultaneously??? Why?
    By Application Development in forum Perl
    Replies: 0
    Last Post: 08-23-2007, 11:38 PM
  4. tcl expect event handling
    By Application Development in forum TCL
    Replies: 0
    Last Post: 03-22-2007, 10:40 PM
  5. Expect to monitor multiple processes
    By Application Development in forum TCL
    Replies: 4
    Last Post: 03-06-2007, 03:44 PM