Starting a subprocess from Python
May 5, 2008
subprocess is a convenient way to fork a new process on Windows/Unix/etc. It obsoletes previous methods such as commands (which does not support Windows) and os.system()/os.popen*/os.spawn*
Here is an example:
import subprocess
cmd_lst = ['exec_file', 'arg1', 'arg2', ...]
subprocess.call(cmd_lst) #return the value returned by the callee
subprocess.check_call(cmd_lst) #return if the callee exits with 0, otherwise raise an error
Leave a Comment
Some HTML allowed:
<a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>
Trackback this post | Subscribe to the comments via RSS Feed