Answers for "capture output of os.system in python"

1

capture output of os.system in python

Capture output of os.system in python
Using popen:

import os
os.popen('cat /etc/services').read()

OR

import subprocess
proc = subprocess.Popen(["cat", "/etc/services"], stdout=subprocess.PIPE, shell=True)
(out, err) = proc.communicate()
print "program output:", out
Posted by: Guest on October-13-2021

Code answers related to "capture output of os.system in python"

Python Answers by Framework

Browse Popular Code Answers by Language