97
import subprocess subprocess.run(["ls", "-l"])
subprocess.call(["ls", "-l"])
84
os.system("some_command < input_file | another_command > output_file")
print(os.popen("ls -l").read())
print subprocess.Popen("echo Hello World", shell=True, stdout=subprocess.PIPE).stdout.read()
print os.popen("echo Hello World").read()
return_code = subprocess.call("echo Hello World", shell=True)
print subprocess.Popen("echo %s " % user_input, stdout=PIPE).stdout.read()
79
import subprocess p = subprocess.Popen('ls', shell=True, stdout=subprocess.PIPE, stderr=subprocess.STDOUT) for line in p.stdout.readlines(): print line, retval = p.wait()
69
import subprocess import sys # Some code here pid = subprocess.Popen([sys.executable, "longtask.py"]) # Call subprocess # Some more code here
DETACHED_PROCESS = 0x00000008 pid = subprocess.Popen([sys.executable, "longtask.py"], creationflags=DETACHED_PROCESS).pid
pid = subprocess.Popen([sys.executable, "longtask.py"], stdout=subprocess.PIPE, stderr=subprocess.PIPE, stdin=subprocess.PIPE)
52
import os os.system("your command")