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


product

Excelify has been changed to Laravel Package installation version

Excelify is a set of Excel data conversion tools developed by me using Laravel. This tool, the current record, Through this conversion tool, I successfully converted the Excel dictionary file authorized by the Ministry of Education to the public, which contains about 160,000 records and more than 5,000 records of idioms. All are converted into the SQL format I need. This article will discuss the functions of Excelify and share some precautions for use.

laravel

Let's run Laravel

If you haven't heard of D-Laravel, let me introduce it. D-Laravel is a Laravel and docker execution environment built with docker-compose. Let us quickly generate Laravel projects through simple bash. This article teaches you how to use the docker image provided by D-Laravel to build a swoole execution development environment. After reading this article, you should be able to quickly create a swoole execution environment through D-Laravel.

git

Forcibly clear all data in the remote repo

Forcibly clear all data in the remote repo