Reading stdout and stderr of an external program

Thomas Jollans thomas at jollans.com
Mon Jul 2 12:01:00 EDT 2007


On Monday 02 July 2007, Murali wrote:
> Hi Python programmers,
>
> I need to be able to read the stdout and stderr streams of an external
> program that I launch from my python script. os.system( 'my_prog' +
> '>& err.log' ) and was planning on monitoring err.log and to display
> its contents. Is this the best way to do this?

No. The best way to do this is with Popen, as it is portable and avoids the 
extranous file.


-- 
      Regards,                       Thomas Jollans
GPG key: 0xF421434B may be found on various keyservers, eg pgp.mit.edu
Hacker key <http://hackerkey.com/>:
v4sw6+8Yhw4/5ln3pr5Ock2ma2u7Lw2Nl7Di2e2t3/4TMb6HOPTen5/6g5OPa1XsMr9p-7/-6



More information about the Python-list mailing list