• linkedu视频
  • 平面设计
  • 电脑入门
  • 操作系统
  • 办公应用
  • 电脑硬件
  • 动画设计
  • 3D设计
  • 网页设计
  • CAD设计
  • 影音处理
  • 数据库
  • 程序设计
  • 认证考试
  • 信息管理
  • 信息安全
菜单
linkedu.com
  • 网页制作
  • 数据库
  • 程序设计
  • 操作系统
  • CMS教程
  • 游戏攻略
  • 脚本语言
  • 平面设计
  • 软件教程
  • 网络安全
  • 电脑知识
  • 服务器
  • 视频教程
  • vbs
  • DOS/BAT
  • hta/htc
  • python
  • perl
  • VBA
  • ColdFusion
  • ruby
  • PowerShell
  • Lua
  • Golang
  • linux shell
您的位置:首页 > 脚本语言 >python > python 捕获 shell/bash 脚本的输出结果实例

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

作者:jingxian 字体:[增加 减小] 来源:互联网

jingxian 通过本文主要向大家介绍了bash shell脚本,shell脚本 bin/bash,bash shell,bash shell是什么,bash shell教程等相关知识,希望对您有所帮助,也希望大家支持linkedu.com www.linkedu.com

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

</div>

您可能想查找下面的文章:

  • python 捕获 shell/bash 脚本的输出结果实例
  • python 捕获 shell/bash 脚本的输出结果实例
  • 使用Python脚本在Linux下实现部分Bash Shell的教程

相关文章

  • 用Python将IP地址在整型和字符串之间轻松转换
  • 跟老齐学Python之编写类之一创建实例
  • 用Python将动态GIF图片倒放播放的方法
  • Python语言的12个基础知识点小结
  • 利用Python爬取可用的代理IP
  • Python中list列表的一些进阶使用方法介绍
  • python根据日期返回星期几的方法
  • python正则分组的应用
  • Python使用QQ邮箱发送Email的方法实例
  • Python实现将一个大文件按段落分隔为多个小文件的简单操作方法

文章分类

  • vbs
  • DOS/BAT
  • hta/htc
  • python
  • perl
  • VBA
  • ColdFusion
  • ruby
  • PowerShell
  • Lua
  • Golang
  • linux shell

最近更新的内容

    • python使用PyGame绘制图像并保存为图片文件的方法
    • python实现爬虫统计学校BBS男女比例之多线程爬虫(二)
    • python开启多个子进程并行运行的方法
    • python处理html转义字符的方法详解
    • python中enumerate函数遍历元素用法分析
    • Python的Flask框架中Flask-Admin库的简单入门指引
    • Python标准库之随机数 (math包、random包)介绍
    • 用Python实现服务器中只重载被修改的进程的方法
    • Python中字典映射类型的学习教程
    • Python中的Numpy入门教程

关于我们 - 联系我们 - 免责声明 - 网站地图

©2020-2025 All Rights Reserved. linkedu.com 版权所有