title: how to capture subprocess error
body: <p>In Python, I run an exe made using FORTRAN. I use the <code>subprocess</code> module. that exe accesses and writes to several files. If I make those files readonly, I see the following trace in my Python console.</p>
  
  <p>I tried by using <code>try</code>, <code>except</code> statements. But I could not capture the error. I also tried using <code>p.stdout.readline()</code>. But was unsuccessful.</p>
  
  <p>Is there a systematic way to capture this sort of errors.</p>
  
  <p>Code:</p>
  
  <pre><code>import subprocess
  p = subprocess.Popen('C:\\TGSSR\\test.exe' , shell=True, stdout=subprocess.PIPE)
  </code></pre>
  
  <p>Traceback:</p>
  
  <pre><code>forrtl: severe (9): permission to access file denied, unit 6, file C:\test\mar22_SSOUT\RawReadLog.dat
  
  Image              PC        Routine            Line        Source             
  test.exe           0116DC40  Unknown               Unknown  Unknown
  test.exe           0113D42F  Unknown               Unknown  Unknown
  test.exe           0112AE97  Unknown               Unknown  Unknown
  test.exe           0112A1DA  Unknown               Unknown  Unknown
  test.exe           0110D746  Unknown               Unknown  Unknown
  test.exe           0108B9AC  Unknown               Unknown  Unknown
  test.exe           01173FE3  Unknown               Unknown  Unknown
  test.exe           011588F5  Unknown               Unknown  Unknown
  kernel32.dll       76D33677  Unknown               Unknown  Unknown
  ntdll.dll          77A39F42  Unknown               Unknown  Unknown
  ntdll.dll          77A39F15  Unknown               Unknown  Unknown
  </code></pre>