[Tutor] os.popen() questions (original) (raw)

Magnus Lyckå magnus at thinkware.se
Sat Jul 24 12:42:11 CEST 2004


At 19:19 2004-07-23 -0400, Brian van den Broek wrote:

import os theprogram = r'C:\clamav-devel\bin\clamscan.exe' os.chdir('C:/testdir') a = os.popen('dir .').readlines() # works fine os.system('start %s > testing.txt' %theprogram) b = os.popen(theprogram).readlines() print b # prints as [] print a

Are you sure that clamscan.exe writes to stdout? Maybe it actually writes to stderr? I don't think popen.readlines will catch that (but DOS ">" will).

You might want to use popen3 or popen4 instead.

-- Magnus Lycka (It's really Lyckå), magnus at thinkware.se Thinkware AB, Sweden, www.thinkware.se I code Python ~ The Agile Programming Language



More information about the Tutor mailing list