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.

big5

PHP version of big5 to utf8 program

Do you have a large number of big5-encoded php, js or html pages that need to be transcoded? Here is my original php transcoding method, which uses PHP programs to transcode files. The transcoding of database big5 via latin1 is more complicated, so this article will not discuss it. The most important thing before transcoding is to control the version of your target folder, so that after transcoding, you can compare whether there is a normal transcoding success.  Or when there is a problem, you can also perform the restoration method.

CCC IM supports various social platforms OAuth authentication login and guest message

CCC IM supports multiple social platforms to log in, such as Google, Facebook, Twitter, Line, Github , and added a guest message function, you can leave a message without logging in, and you can also create a chat channel.