Skip to content

Instantly share code, notes, and snippets.

@yoxisem544
Created July 9, 2015 16:46
Show Gist options
  • Save yoxisem544/fe17a2153ac13462fd91 to your computer and use it in GitHub Desktop.
Save yoxisem544/fe17a2153ac13462fd91 to your computer and use it in GitHub Desktop.
from subprocess import Popen, PIPE
import tempfile
with tempfile.TemporaryFile() as tempf:
proc = Popen(['echo', 'a', 'b'], stdout=tempf)
proc.wait()
tempf.seek(0)
print tempf.read()
proc = Popen(['ifconfig'], stdout=tempf)
proc.wait()
tempf.seek(0)
print tempf.read()、''
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment