os.popen() not executing command on windows xp

nic nocl123 at gmail.com
Thu Jan 11 12:09:30 EST 2007


Justin Ezequiel wrote:
> > import os
> > a = os.popen('"c:\Program Files\Grisoft\AVG Free\avgscan.exe"
> > "c:\program files\temp1\test1.txt"')
> > print a.read()
> >
>
> use raw strings
>
> e.g., instead of '"c:...\avgscan...'
> use r'"c:...\avgscan...'
>
> http://www.ferg.org/projects/python_gotchas.html#contents_item_2

Sorry I initally had retyped the code to replace some variables to make
it more clear, I already had them as raw strings:

import os
pstr = r'"c:\Program Files\Grisoft\AVG Free\avgscan.exe" "c:\program
files\temp1\test1.txt"'
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
files\temp1\test1.txt"

The problem remains popen won't execute this line as it does when
inputted manually to command prompt.




More information about the Python-list mailing list