Replacing os.popen() : Subprocess : Buildin Module PYTHON TUTORIALS


PYTHON TUTORIALS » Buildin Module » Subprocess »

 

Replacing os.popen()


from subprocess import Popen, PIPE
f = Popen(('uname', '-a'), stdout=PIPE).stdout
data = f.readline()
f.close()
print data,
        
f = Popen('who', stdout=PIPE).stdout
data = eachLine.strip() for eachLine in f ]
f.close()
for eachLine in data:
   print eachLine



Leave a Comment / Note


 
Verification is used to prevent unwanted posts (spam). .


PYTHON TUTORIALS

 Navioo Buildin Module
» Subprocess