[Tutor] Dudes with os.spawnlp
Jonas Melian
jonasmg at softhome.net
Sun May 29 14:13:22 CEST 2005
This code run 'X -configure' using $PATH for looking for its path
::
try:
#retcode = call("X" + " -configure", shell=True) # 2.4
code_return = os.spawnlp(os.P_WAIT, "X", "X", "-configure")
if retcode < 0:
print >>sys.stderr, "Child was terminated by signal", -retcode
else:
print >>sys.stderr, "Child returned", retcode
except OSError, e:
print >>sys.stderr, "Execution failed:", e
::
1) The OSError exception never is runned. I tested with an command that
doesnt exist (Xe)
2) For redirecting command output message, I think that I could to use:
os.spawnlp(os.P_WAIT, "X", "X", "-configure", "&>/dev/null")
But, is there any way more elegant in python?
3) That command built a file. Is it possible knows its name?
Thanks in advance!
More information about the Tutor
mailing list