Last active
June 15, 2017 00:37
-
-
Save ashwinrs/1b3808693f878980fbc11ed83974afe2 to your computer and use it in GitHub Desktop.
Execute shell command from python
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import subprocess | |
def execute_binary(args): | |
popen = subprocess.Popen(args, stdout=subprocess.PIPE, stderr=subprocess.PIPE) | |
stdout,stderr = popen.communicate() | |
if popen.returncode != 0: | |
print("Process exited non zero: {0}".format(popen.returncode)) | |
return False | |
return True | |
execute_binary(['ls', '-a', '-l']) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment