Last active
December 28, 2015 08:49
-
-
Save ttback/7474582 to your computer and use it in GitHub Desktop.
Passing sys.stdin to sys.stdin of a subprocess
This file contains 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
#!/usr/bin/python2.7 | |
import subprocess | |
import os | |
import sys | |
from tempfile import NamedTemporaryFile | |
with NamedTemporaryFile('w', delete=False) as fout: | |
fout.write('import sys; print sys.stdin') | |
print subprocess.check_output(['python2.7', fout.name], stdin=sys.stdin) | |
os.unlink(fout.name) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment