I want to invoke a script, piping the contents of a string to its stdin and retrieving its stdout.
I don\'t want to touch the real filesystem so I can\'t create real
Use Popen.communicate instead of subprocess.check_output.
Popen.communicate
subprocess.check_output
from subprocess import Popen, PIPE p = Popen([script_name, "-"], stdin=PIPE, stdout=PIPE, stderr=PIPE) stdout, stderr = p.communicate("this is some input")