Skip to content

Instantly share code, notes, and snippets.

@seansullivan
Created September 9, 2013 18:25
Show Gist options
  • Save seansullivan/6499542 to your computer and use it in GitHub Desktop.
Save seansullivan/6499542 to your computer and use it in GitHub Desktop.
Python call_command for calling command line in script.
def call_command(command):
process = subprocess.Popen(command.split(' '),
stdout=subprocess.PIPE,
stderr=subprocess.PIPE)
return process.communicate()
# Ex usage: call_command("sudo mount {dev} {mnt}".format(dev=device_path, mnt=mount_path))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment