Skip to content

Instantly share code, notes, and snippets.

@ashwinrs
Last active June 15, 2017 00:37
Show Gist options
  • Save ashwinrs/1b3808693f878980fbc11ed83974afe2 to your computer and use it in GitHub Desktop.
Save ashwinrs/1b3808693f878980fbc11ed83974afe2 to your computer and use it in GitHub Desktop.
Execute shell command from python
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