首页 > 后端开发 > Python教程 > python 捕获shell脚本的输出结果实例

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

高洛峰
发布: 2017-02-06 13:32:53
原创
1428 人浏览过

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中文网!

相关标签:
本站声明
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系admin@php.cn
最新问题
linux - shell脚本中怎么判断发行版?
来自于 1970-01-01 08:00:00
0
0
0
bash - linux shell 脚本自动执行手动操作
来自于 1970-01-01 08:00:00
0
0
0
php - shell脚本找不到目录或文件
来自于 1970-01-01 08:00:00
0
0
0
linux - 如何暂停运行中python脚本
来自于 1970-01-01 08:00:00
0
0
0
centos7中怎么用shell脚本执行laravel的路由?
来自于 1970-01-01 08:00:00
0
0
0
热门教程
更多>
最新下载
更多>
网站特效
网站源码
网站素材
前端模板