IdentifiantMot de passe
Mot de passe oublié ?Je m'inscris ! (gratuit) Replacing os.system() Replacing os.system()

sts = os.system("mycmd" + " myarg")
p = Popen("mycmd" + " myarg", shell=True)
sts = os.waitpid(, 0)


  • Calling the program through the shell is usually not required.
  • It's easier to look at the returncode attribute than the exit status.

A more realistic example would look like this:

    retcode = call("mycmd" + " myarg", shell=True)
    if retcode < 0:
        print >>sys.stderr, "Child was terminated by signal", -retcode
        print >>sys.stderr, "Child returned", retcode
except OSError, e:
    print >>sys.stderr, "Execution failed:", e

See About this document... for information on suggesting changes.