python 执行shell
2016-04-14 14:03
393 查看
一、import os
ex:
1.os.system('ls') ----并不能得到返回值
2.output = os.popen('ls')
res = output.read() ----能得到输出,但是不能得到程序执行的返回值
二、import commands
ex:
三、subprocess
ex:
1.os.system('ls') ----并不能得到返回值
2.output = os.popen('ls')
res = output.read() ----能得到输出,但是不能得到程序执行的返回值
二、import commands
ex:
>>> import commands >>> commands.getstatusoutput('ls') (0, 'a\nb\nc') >>> commands.getoutput('ls') 'a\nb\nc' >>> commands.getstatus('/bin/ls') '-rwxr-xr-x 1 root root 109208 Oct 15 2014 /bin/ls'
三、subprocess
相关文章推荐
- Xshell 码
- 【Shell】linux中shell变量$#,$@,$0,$1,$2的含义解释 && set 关键字使用
- shell递归下载repo网站文件
- -bash: rz: command not found
- windows azure powershell登录方式
- 高级bash脚本编辑
- gitshell同时用于github与gitlab
- Shell升级,/bin/bash版本号4.1到4.3
- Linux下Bash编程之算术运算符详解(三)
- ssh远程登陆linux显示-bash-4.1$解决方法
- bash脚本笔记随记
- SHELL笔记之管家
- Linux下文件 ~/.bashrc 和 ~/.bash_profile 和 /etc/bashrc 和 /etc/profile 的区别 | 用户登录后加载配置文件的顺序
- learning bash-chap 01
- Windows客户端 SSH 远程连接Windows服务器(PowerShell Server)
- shell 删除奇数偶数行
- .bashrc 大数据版个人配置
- shell脚本学习笔记 (流编辑器sed)
- hbase shell基础和常用命令详解
- 数据库七天自动备份(shell)