欢迎您访问程序员文章站本站旨在为大家提供分享程序员计算机编程知识!
您现在的位置是: 首页  >  后端开发

python 捕获shell脚本的输出结果实例

程序员文章站 2022-06-03 10:57:14
...
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]

以上就是小编为大家带来的python 捕获shell脚本的输出结果实例全部内容了,希望大家多多支持PHP中文网~

更多python 捕获shell脚本的输出结果实例相关文章请关注PHP中文网!