Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR PYTHON

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
 
PREVIOUS NEXT
Tagged: #capture #output #python
ADD COMMENT
Topic
Name
8+1 =