• 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实现计算资源图标crc值的方法
  • python使用opencv读取图片的实例
  • 解决Python中字符串和数字拼接报错的方法
  • Python入门学习之字符串与比较运算符
  • python logging类库使用例子
  • 一篇文章入门Python生态系统(Python新手入门指导)
  • 在Python中利用Into包整洁地进行数据迁移的教程
  • python文件读写并使用mysql批量插入示例分享(python操作mysql)
  • python处理二进制数据的方法
  • 使用Python内置的模块与函数进行不同进制的数的转换

文章分类

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

最近更新的内容

    • python使用PyV8执行javascript代码示例分享
    • python使用Image处理图片常用技巧分析
    • python修改字典内key对应值的方法
    • 在Mac OS上搭建Python的开发环境
    • 将Emacs打造成强大的Python代码编辑工具
    • Python中的pprint折腾记
    • python使用Queue在多个子进程间交换数据的方法
    • Python显示进度条的方法
    • 仅用50行Python代码实现一个简单的代理服务器
    • 简介Django中内置的一些中间件

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

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