Home > Backend Development > Python Tutorial > python capture shell script output example

python capture shell script output example

高洛峰
Release: 2017-02-06 13:32:53
Original
1406 people have browsed it

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!

Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template