by Devin Yang

建立于: 6年前 ( 更新: 6年前 )

最简化版本的Python系统命令运行范本

#!/usr/local/bin/python3
# -*- coding: utf-8 -*-
from subprocess import Popen, PIPE, STDOUT
#运行的命令
command='ls -l'.split()
proc=Popen(command , stdout=PIPE,stderr=PIPE, universal_newlines=True);
output, error = proc.communicate()

#显示运行结果
if(proc.poll()==0):
     print(output)
else:
     print("{} Error\n".format(error))


 

Tags:

Devin Yang

文章内容无法一一说明,如果您有什么不了解处,欢印提问哦:)

No Comment

Post your comment

需要登入才可留言!

类似文章


linux

公钥验证之多个ssh的组态档

我们使用ssh公钥验证时,通常会在~/.ssh/config添加相关设置。 如果说有些是公司用的或是家里用的,是否可以使用多个config呢? 其实可以的,我们能git透过Include加载公司共用,有版本控制的config。

openssl

如何移除PEM的密码

您可以使用openssl rsa命令删除密码。 我们传入SSL .key并获得一个.key文档作为输出。

php,docker,dlaravel

我创建的phpenv容器环境简单介绍

没时间拍介绍影片,我就来随便抓些画面介绍我使用的容器环境deviny/phpenv。https://github.com/DevinY/phpenvphpenv算是我之前D-Laravel开源项目的进化版本,概念上延用了很多Dlaravel的操作方式。容器的更新上偏向使用者自行控制去Build自己的image,所以我不太会去更动版号了,其实D-Laravel的php版号,好像我也很久没动啦:p