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


Raiders D-Laravel configuration file

D-Laravel is a PHP execution environment using Docker, which puts all services into containers for execution. Database service (db), web server service (web), PHP-FPM service (php)... etc., By defining the docker-compose.yml file, we can easily adjust the database version or PHP version. D-Laravel also creates a simple bash, which can help us adopt docker more quickly to create Laravel projects and complete database settings. Even if you are just a PHP developer, you can actually create your own development environment through D-Laravel. Next, let us understand the settings made by D-Laravel through the official Docker documents.

redis

Redis Key Notes

Redis is an advanced NoSQL key-value data storage, also known as a data structure server. Because it has powerful data types, such as Strings, Hashes, Lists, Sets, Stored Sets, Bitmas, and HyperLogLogs. By default, Redis stores all data in memory, so the reading and writing speed is very fast. He can also save the data permanently on the disk, such as snapshotting and journaling we know.

laravel,oauth2

My most used Laravel passport directives

Laravel provides quite a lot of useful packages, such as Passport is one of them, when the website needs to set up its own OAuth2 authentication host, it really saves time and effort. Take this site as an example, because the front-end and back-end separation mechanisms are adopted (there are two different Laravel projects), and I verify them through the front-end WEB. Basically, I have many other different projects, and they all rely on OAuth2 provided by Laravel to handle cross-domain authentication.