python获取shell返回值
来源:互联网 发布:苹果隐藏图标软件 编辑:程序博客网 时间:2024/05/20 05:09
在python中调用shell,为了实现流程控制,需要捕获shell的返回值
as咱们都知道,shell正常执行的返回为0,失败或异常为非0,
在python中可以通过,如下方式获取到执行的返回状态码
>>> import commands
>>> commands.getstatusoutput('ls /bin/ls')
(0, '/bin/ls')
>>> commands.getstatusoutput('cat /bin/junk')
(256, 'cat: /bin/junk: No such file or directory')
>>> commands.getstatusoutput('/bin/junk')
(256, 'sh: /bin/junk: not found')
>>> commands.getoutput('ls /bin/ls')
'/bin/ls'
>>> commands.getstatus('/bin/ls')
'-rwxr-xr-x 1 root 13352 Oct 14 1994 /bin/ls'
0 0
- python获取shell返回值
- python获取shell命令返回值
- python获取shell命令返回值;python获取进程ID,杀进程
- python调用其它脚本:pig,python,shell等等 (如何获取pig脚本执行的返回值)
- C++ 中获取shell脚本返回值
- java调用shell获取返回值
- 获取shell退出返回值 -- sh
- shell:获取函数的返回值
- shell 获取 postgresql返回字段值
- 远程执行shell获取返回值方法
- 如何获取shell函数的返回值及shell命令的返回值?
- 如何获取shell函数的返回值及shell命令的返回值?
- python threading获取线程函数返回值
- python threading获取线程函数返回值
- python调用存储过程,获取返回值
- linux下,获取python expect 返回值
- java执行python获取返回值
- python多线程,获取多线程的返回值
- 深夜等待去冰封深处
- Fragment保存状态
- EL学习过程(二)
- grub rescue模式下启动并修复
- IIS+PHP+MYSQL安装配置
- python获取shell返回值
- cocos2d-x游戏开发 跑酷(四) 关联物理世界
- Java编程基础之IO流
- 解读Nodejs多核处理模块cluster
- Android进程与线程基本知识
- 不用光驱装XP流程
- C语言 时间类操作
- C#开机自启动
- VC6.0 设置