by Devin Yang
(This article was automatically translated.)

Published - 6 years ago ( Updated - 6 years ago )

The most simplified version of the Python system command execution template

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

#display execution result
if(proc. poll()==0):
     print(output)
else:
     print("{} Error\n".format(error))


 

Tags:

Devin Yang

Feel free to ask me, if you don't get it.:)

No Comment

Post your comment

Login is required to leave comments

Similar Stories


Polymer,Webcomponents

Just to be different, CCC IM beta adopts Laravel+Polymer 2.0 development version and is going online

Using WSS encryption, the community chat program developed using Laravel framework + Polymer 2.0 is currently under development. The goal is to create a chat room + IM suitable for developers to discuss. Currently, you can create chat channels and invite link functions. In the future, you will consider adding One on One one-to-one video calls and electronic whiteboard functions. If you want to know more about Polymer or CCC IM, click here to have a look.

docker,phpenv

Unable to ping host.docker.internal on Linux

You can check with docker version, confirm that the version is Docker v20.10+, you can add extra_hosts as follows:

linux

haproxy 1.8.9 compilation record

Record the process of compiling haproxy 1.8.9 under Ubuntu.