passing data to subprocess.check_output
<p>I want to invoke a script, piping the contents of a string to its stdin and retrieving its stdout.</p>

<p>I don't want to touch the real filesystem so I can't create real temporary files for it.</p>

<p>using <code>subprocess.check_output</code> I can get whatever the script writes; how can I get the input string into its stdin though?</p>

<pre><code>subprocess.check_output([script_name,"-"],stdin="this is some input")
Traceback (most recent call last):
  File "&lt;stdin&gt;", line 1, in &lt;module&gt;
  File "/usr/lib/python2.7/subprocess.py", line 537, in check_output
    process = Popen(stdout=PIPE, *popenargs, **kwargs)
  File "/usr/lib/python2.7/subprocess.py", line 672, in __init__
    errread, errwrite) = self._get_handles(stdin, stdout, stderr)
  File "/usr/lib/python2.7/subprocess.py", line 1043, in _get_handles
    p2cread = stdin.fileno()
AttributeError: 'str' object has no attribute 'fileno'
</code></pre>
