Some Python Examples
← prev | next →     Top-level ToC     /managing-processes.html     (printable version)
import os, subprocess

os.chdir(os.environ['HOME'])

# Shell-out. Raises an exception if exit code not zero.
subprocess.check_call(['tar', 'czf', 'docs.tar.gz', 'docs'])

# Returns output from running shell command:
some_output = subprocess.check_output(['ls', '-l'])