Launch a shell command with in a python script, wait for the termination and return to the script

subprocess: The subprocess module
allows you to spawn new processes,
connect to their input/output/error
pipes, and obtain their return codes.

http://docs.python.org/library/subprocess.html

Usage:

import subprocess
process = subprocess.Popen(command, shell=True, stdout=subprocess.PIPE)
process.wait()
print process.returncode

Leave a Comment