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


docker,php,cli

MacOS's php is not powerful, use docker to execute laravel installer

It's very simple, just add an "alias" alias laravel='docker run --rm -v ${PWD}:/var/www/html -v ~/.dlaravel/cache:/home/dlaravel/.composer /cache -ti deviny/fpm:8.1.10 /home/dlaravel/.composer/vendor/bin/laravel'

linux

Load the environment variables of .env to the system

Load the environment variables of .env to the system

docker,laravel

It's super easy to build a Lravel development environment with Docker

Are you ready for the Laravel 5.5 system environment? laravel/framework 5.5.x-dev requires php >=7.0 -> your PHP version (5.6.30) does not satisfy that requirement. This article describes how to create a Laravel development environment using Docker. With the simple to explosive D-Laravel simple bash, Don't say that I can't set up a Laravel development environment.