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

 更新时间:2017年01月04日 11:35:57   投稿:jingxian  
下面小编就为大家带来一篇python 捕获shell脚本的输出结果实例。小编觉得挺不错的,现在就分享给大家,也给大家做个参考。一起跟随小编过来看看吧

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

相关文章

最新评论