Skip to content

Instantly share code, notes, and snippets.

@terryjbates
Created November 29, 2012 01:21
Show Gist options
  • Save terryjbates/4166098 to your computer and use it in GitHub Desktop.
Save terryjbates/4166098 to your computer and use it in GitHub Desktop.
Python code snippet with processing of stdout output gotten from Popen
#!/usr/bin/env python
import subprocess
p = subprocess.Popen(["/bin/ls", "-l"], stdin=subprocess.PIPE, stdout=subprocess.PIPE)
for line in p.stdout:
print line.strip()
for output in file.stdout.readlines():
if "FontCache" in output:
outputfile.write(output)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment