#2 method to get the exit code/status from child process

closed
nobody
None
5
2006-02-02
2004-08-18
Anonymous
No

I would like a way to get the exit status of the child
process.

If isalive() returns false, I would like to call a
getstatus() method to find the exit status of the child
process that just ended.

Discussion

  • Logged In: NO

    I found a work around:

    At the end of the command put
    ; echo "EXITSTATUS: $?\."
    and create a regex for expect to grab it.

    If you are using a pipeline you can use the bash variable
    PIPESTATUS to grab the exit status you want:

    ; echo "EXITSTATUS: ${PIPESTATUS[0]}\."

     
  • Noah Spurrier
    Noah Spurrier
    2006-02-02

    • status: open --> closed
     
  • Noah Spurrier
    Noah Spurrier
    2006-02-02

    Logged In: YES
    user_id=59261

    This value can be read through the 'exitstatus' attribute.
    See also terminated, exitstatus, signalstatus.

    child = pexpect.spawn ("my_program")

    child.expect (pexpect.EOF)

    print "Exit status:", child.exitstatus