popen2 question

Rajarshi Guha rajarshi at presidency.com
Wed Jul 17 15:09:58 EDT 2002


Hi,
  I'm writing a driver routine for some fortran programs. basically I use
the statement:

cin, cout = popen2.popen2('qnetin')

I provide input like:

cin.write('train\n10\n\n1000\n')

The write's work fine. However when at a certain point, the fortran
program will output to stdout, which I catch with

line = cout.readline()

But after reading 2 lines of output like this, the fortran program
crashes with the error:

Input/Output Error 173: Broken pipe

   In Procedure: main program
        At Line: 297

      Statement: Formatted WRITE
           Unit: 6
   Connected To: Stdout
           Form: Formatted
         Access: Sequential
Records Read   : 0
Records Written: 5

End of diagnostics

Why does the popen2 command work for the first 2 lines of output and then
fail on the third? 

Any suggestions would be helpful.
TIA



More information about the Python-list mailing list