Skip to content

Instantly share code, notes, and snippets.

@pnavarro-algometrics
Created April 27, 2011 15:19
Show Gist options
  • Save pnavarro-algometrics/944443 to your computer and use it in GitHub Desktop.
Save pnavarro-algometrics/944443 to your computer and use it in GitHub Desktop.
Capture the output of a command line command with subprocess
# Capture the output of a process
import shlex
import subprocess
cmdline = 'date --help'
p = subprocess.Popen(shlex.split(cmdline), stdout=subprocess.PIPE)
print(p.stdout.read())
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment