#!/usr/bin/python
## get subprocess module
import subprocess
## call date command ##
p = subprocess.Popen("date", stdout=subprocess.PIPE, shell=True)
## Talk with date command i.e. read data from stdout and stderr. Store this info in tuple
## Interact with process: Send data to stdin. Read data from stdout and stderr,
## until end-of-file is reached.Wait for process to terminate. The optional input
## argument should be a string to be sent to the child process, or None,
## if no data should be sent to the child. ##
(output, err) = p.communicate()
## Wait for date to terminate. Get return returncode ##
p_status = p.wait()
print "Command output : ", output
print "Command exit status/return code : ", p_status
## from: http://www.cyberciti.biz/faq/python-run-external-command-and-get-output/
以上就是小编为大家带来的python 捕获 shell/bash 脚本的输出结果实例全部内容了,希望大家多多支持~
免责声明:本站资源来自互联网收集,仅供用于学习和交流,请遵循相关法律法规,本站一切资源不代表本站立场,如有侵权、后门、不妥请联系本站删除!
更新日志
- 【原神】V5.0攻略 | 纳塔入门手册·燃素定量篇
- 战略游戏《盟军敢死队:起源》已于Steam上线试玩版
- 这几天,有多少玩家被魔性的“沙威玛”洗脑了?
- 英国9月游戏销量排行榜:《EA Sports FC 25》领跑
- 大侠立志传囚龙之地任务怎么做 任务图文攻略
- 新月同行碎银子技能介绍 六星绑定者碎银子
- 炉石传说T0天梯卡组推荐 2024最强卡组一览
- 英雄联盟世界赛2024门票多少钱 S14世界赛2024门票价格介绍
- lols14全球总决赛门票去哪买 s14世界赛2024门票购买方法
- dnf手游决斗场商店买什么好 决斗场商店高性价比物品购买推荐
- IGN评价《寂静岭2RE》:最痛苦却最成功的恐怖体验
- 西班牙全跨性别足球队首次亮相 将正式踢比赛
- 《怪猎荒野》新接待员超受欢迎 玩家:新老婆来了!
- 王钰《尘雾涅槃——王钰古筝独奏专辑》[320K/MP3][148.89MB]
- 王钰《尘雾涅槃——王钰古筝独奏专辑》[FLAC/分轨][298.09MB]