Created
April 27, 2011 15:19
-
-
Save pnavarro-algometrics/944443 to your computer and use it in GitHub Desktop.
Capture the output of a command line command with subprocess
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
# 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