by Devin Yang

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

最简化版本的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,security

ssh-agent及ssh-add认证代理员

在ssh的核心包中的进程诸如,scp、ssh、ssh-add、ssh-agent、sshd及ssh-keygen 让我们来谈谈ssh-agent及ssh-add使用情境吧。 在开始前先来看看这些命令用途的简介:

ssl,haproxy,certbot

完美SSL证书自动化更新环境(HAProxy加certbot)

HAProxy的重载速度很快,跟本感觉不出有重启,所有证书都给HAProxy处理真的很方便。主机环境需求,请确认您已有下面两个命令(Ubuntu怎么装? apt-get install -y haproxy cerbot,我猜的,如果不是请自行Google)

composer

如何知道,自己composer环境的目录在那里

查自己环境的composer家目录