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使用情境吧。 在开始前先来看看这些命令用途的简介:

docker,laravel

如何使用多个YAML档,运行多个docker的container服务

这个影片介绍如何用docker-compose命令,指定多个YAML结构语言设置档,来创建容器的运行,并且介绍在D-Laravel的使用环境中,我们如何透过使用.env的方式,简化docker-compose的启动命令。

docker,dlaravel

D-Laravel 1.5.5变更说明

D-Laravel的fpm image在php 7.2.1以前是使用docker php官方的dockerfile重build的, 并且所以我可以指定了fpm的默认的owner是dlaravel, --with-fpm-user=USER Set the user for php-fpm to run as. (default: nobody) --with-fpm-group=GRP Set the group for php-fpm to run as.