title: subprocess.Popen() IO redirect
body: <p>Trying to redirect a subprocess' output to a file.</p>
  
  <p>server.py:</p>
  
  <pre><code>while 1:
      print "Count " + str(count)
      sys.stdout.flush()
      count = count + 1
      time.sleep(1)
  </code></pre>
  
  <p>Laucher:</p>
  
  <pre><code>cmd = './server.py &gt;temp.txt'
  args = shlex.split(cmd)
  server = subprocess.Popen( args )
  </code></pre>
  
  <p>The output appear on screen, <code>temp.txt</code> remains empty.
  What am I doing wrong?</p>
  
  <p>As background I am trying to capture the output of a program that has already been written.</p>
  
  <p>I cannot use:</p>
  
  <pre><code>server = subprocess.Popen(
                  [exe_name],
                  stdin=subprocess.PIPE, stdout=subprocess.PIPE)
  </code></pre>
  
  <p>as the program may not flush.
  Instead I was going to redirect output through a fifo. This works fine if I manually launch server.py but obviously not if I <code>Popen()</code> cause redirect doesnt work.
  <code>ps -aux</code> shows that <code>server.py</code> was launched correctly.</p>