title: In Python how to pipe a string into an executables stdin?
body: <p>On Windows I have a program (prog.exe) that reads from stdin. In python I want to pipe a string as the input to its stdin. How to do that?</p>
  
  <p>Something like:</p>
  
  <pre><code>subprocess.check_output("echo {0} | myprog.exe".format(mystring)) 
  </code></pre>
  
  <p>or (to make the args a list)</p>
  
  <pre><code>subprocess.check_output("echo {0} | myprog.exe".format(mystring).split())
  </code></pre>
  
  <p>doesn't seem to work. It gave me:</p>
  
  <pre><code>WindowsError: [Error 2] The system cannot find the file specified
  </code></pre>
  
  <p>I also tried to use the "stdin" keyword arg with StringIO (which is a file-like object)</p>
  
  <pre><code>subprocess.check_output(["myprog.exe"], stdin=StringIO(mystring))
  </code></pre>
  
  <p>Still no luck - check_output doesn't work with StringIO.</p>