title: Python: subprocess.call, stdout to file, stderr to file, display stderr on screen in real time
body: <p>I have a command line tool (actually, several) that I am writing a wrapper for in Python. </p>
  
  <p>The tool is generally used like this:</p>
  
  <pre><code> $ path_to_tool -option1 -option2 &gt; file_out
  </code></pre>
  
  <p>The user gets the output written to file_out, and is also able to see various status messages of the tool as it is running. </p>
  
  <p>I want to replicate this behavior, while also logging stderr (the status messages) to a file. </p>
  
  <p>What I have is this:</p>
  
  <pre><code>from subprocess import call
  call(['path_to_tool','-option1','option2'], stdout = file_out, stderr = log_file)
  </code></pre>
  
  <p>This works fine EXCEPT that stderr is not written to the screen. 
  I can add code to print the contents of the log_file to the screen of course, but then the user will see it after everything is done rather than while it is happening. </p>
  
  <p>To recap, desired behavior is:</p>
  
  <ol>
  <li>use call(), or subprocess()  </li>
  <li>direct stdout to a file </li>
  <li>direct stderr to a file, while also writing stderr to the screen in real time as if the 
  tool had been called directly from the command line.</li>
  </ol>
  
  <p>I have a feeling I'm either missing something really simple, or this is much more complicated than I thought...thanks for any help!</p>
  
  <p>EDIT: this only needs to work on Linux.</p>