Re: return codes from os.spawn

Discussion in 'Python' started by Gabriel Genellina, Sep 17, 2007.

  1. En Mon, 17 Sep 2007 08:17:22 -0300, Nirmal <>
    escribi�:

    > Hi,
    >
    > When I try running java through os.spawnv with P_NOWAIT, it returns the
    > process id
    >
    >>>> os.spawnv(os.P_NOWAIT, '$JAVA_HOME/bin', ('java', '$JAVA_HOME/bin/java

    > ex3178 true'))
    > 19524
    >
    > then I removed the command line parameter in the java command to fail
    > ( it
    > should throw an exception) the process and ran it. This time also it
    > returned the process id .
    >
    >>>> os.spawnv(os.P_NOWAIT, '$JAVA_HOME/bin', ('java', '$JAVA_HOME/bin/java

    > ex3178'))
    > 21947
    >
    >
    > And I tried the same by using P_WAIT and it returned the same exit code
    >
    >>>> os.spawnv(os.P_WAIT, '$JAVA_HOME/bin', ('java', '$JAVA_HOME/bin/java

    > ex3178 true))
    > 127
    >>>> os.spawnv(os.P_WAIT, '$JAVA_HOME/bin', ('java', '$JAVA_HOME/bin/java

    > ex3178'))
    > 127


    > please let me know how can we identify that the process is completed
    > successfully or not ?


    All your examples fail to execute your program. The second argument is the
    program being executed, not only the directory. Should be the same as the
    first element of `args`. And the individual arguments should be separated.

    os.spawnv(os.P_WAIT, '$JAVA_HOME/bin/java', ['$JAVA_HOME/bin/java',
    'ex3178', 'true'])

    In this case it's easier to use spawnl:

    os.spawnl(os.P_WAIT, '$JAVA_HOME/bin/java', 'java', 'ex3178', 'true')


    --
    Gabriel Genellina
    Gabriel Genellina, Sep 17, 2007
    #1
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Derek Basch
    Replies:
    2
    Views:
    1,301
    Donn Cave
    Jan 21, 2005
  2. Replies:
    2
    Views:
    2,818
    Malcolm
    Aug 20, 2005
  3. Nirmal

    return codes from os.spawn

    Nirmal, Sep 17, 2007, in forum: Python
    Replies:
    0
    Views:
    310
    Nirmal
    Sep 17, 2007
  4. Ed Hames
    Replies:
    0
    Views:
    372
    Ed Hames
    Apr 16, 2008
  5. Edgardo Hames
    Replies:
    1
    Views:
    346
    Ed Hames
    May 6, 2008
Loading...

Share This Page