Home >Backend Development >Python Tutorial >python capture shell script output example
import subprocess
output =Popen(["mycmd","myarg"], stdout=PIPE).communicate()[0]
import subprocess
p = subprocess .Popen(['ls','-a'], stdout=subprocess.PIPE, stderr=subprocess.PIPE)
out, err = p.communicate()
print out
# work on Unix/Linux only
import commands
print commands.getstatusoutput('wc -l file')[1]
The above is what the editor has done for you The entire content of the examples of python capturing the output results of shell scripts has been brought. I hope everyone will support the PHP Chinese website~
For more articles related to the examples of python capturing the output results of shell scripts, please pay attention to the PHP Chinese website!