title: Capturing Console output that is not written to stdout,stderr?
body: <p>I have an windows application called pregeocode (we lack source), this program basically writes geocoding to an input file. This program doesn't actually write anything to console unless there is an error. This program is generally called from a small Python program (it handles the arguments etc, and does all the fun preprocessing). </p>
  
  <p>We check if it fails by seeing if the output file was actually created (it always returns 0, no matter what). However when it fails subprocess shows that nothing was printed to stderr or stdout. (It processes around a hundred or so successfully, with ussally only a single one being bad, but i would love to be able to see what causes the error)</p>
  
  <p>The small python script calls the application via subprocess.Popen:</p>
  
  <pre><code>argslist = [r'C:\workspace\apps\pregeocode.exe', '-in', inputfilename, '-out', outputfilename, '-gcp', gcp_file]
  p = subprocess.Popen(argslist, stderr=subprocess.PIPE, stdout=subprocess.PIPE)
  print str(p.communicate())
  </code></pre>
  
  <p>Gives the output of:</p>
  
  <pre><code>('', '')
  </code></pre>
  
  <p>However if i run the program manually using the same arguments via cmd, i get the output of:</p>
  
  <pre><code>45 IMAGE_EXTENT_TOO_SMALL
  </code></pre>
  
  <p>(There is around 60 odd different error messages, 45 indicates the error number)</p>
  
  <p>Using the shell=True argument does not change anything, nor can i find anything online about this problem. The actual exe is something that was made in house a long time ago, and we lack the source code for it so i can't see how it prints out the messages.</p>
  
  <p>So why can't subprocess actually capture the stdout or stderr of this?</p>
  
  <p><em>EDIT</em></p>
  
  <pre><code>os.system(" ".join(argslist))
  </code></pre>
  
  <p>properly prints the error message:</p>
  
  <pre><code>45 IMAGE_EXTENT_TOO_SMALL
  </code></pre>
  
  <p><em>EDIT 2</em> </p>
  
  <p>Turns out the application uses ERDAS's toolkit. Their toolkit redirects all stdout/stderr into their logging subsystem. The logging subsystem then rewrites it via "CON". </p>