首页 > 编程 > Python > 正文

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

2019-11-25 16:25:42
字体:
来源:转载
供稿:网友

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脚本的输出结果实例全部内容了,希望大家多多支持武林网~

发表评论 共有条评论
用户名: 密码:
验证码: 匿名发表