subprocess - How to save the data coming from "sudo dpkg -l" in Ubuntu terminal by using python -
subprocess - How to save the data coming from "sudo dpkg -l" in Ubuntu terminal by using python -
how save info coming "sudo dpkg -l" in ubuntu terminal using python, tried way, doesn't work
import os f = open('/tmp/dpgk.txt','w') f.write(os.system('sudo dpkg -l'))
use subprocess.check_output()
capture output of process:
import subprocess output = subprocess.check_output(['sudo', 'dpkg', '-l'])
os.system()
returns exit status of process. above illustration presumes sudo
not going prompt password.
python subprocess
Comments
Post a Comment