os.popen() not executing command on windows xp

Gabriel Genellina gagsl-py at yahoo.com.ar
Fri Jan 12 01:11:30 CET 2007

At Thursday 11/1/2007 14:09, nic wrote:

>import os
>pstr = r'"c:\Program Files\Grisoft\AVG Free\avgscan.exe" "c:\program
>a = os.popen(pstr)
>print a.read()
>I've confirmed the string I'm inputting to os.popen is EXACTLY the same
>as the one I can successfully execute manually in command prompt, so
>when I go:
>print pstr, it yields:
>"c:\Program Files\Grisoft\AVG Free\avgscan.exe" "c:\program
>The problem remains popen won't execute this line as it does when
>inputted manually to command prompt.

I have AVG so I tried this example. That's not the problem. popen 
works ok, avgscan is executed. But the avgscan program does *not* use 
stdout nor stderr to write to the console, so popen can't capture its output.
You can confirm this at the command prompt:

"c:\Program Files\Grisoft\AVG Free\avgscan.exe" "c:\program 
files\temp1\test1.txt" >output.txt 2>&1

You will see the usual progress messages from avgscan *on screen*, 
and when you type output.txt, it's empty. avgscan appears to write 
directly to the console.
You may use the /REPORT option; avgscan /? for details.

Gabriel Genellina
Softlab SRL 


Preguntá. Respondé. Descubrí. 
Todo lo que querías saber, y lo que ni imaginabas, 
está en Yahoo! Respuestas (Beta). 
¡Probalo ya! 

More information about the Python-list mailing list