popen eating quotes?
rtw at freenet.REMOVE.co.uk
Mon Aug 4 02:19:19 CEST 2003
Bryan wrote in news:LOgXa.57808$o%2.28737 at sccrnsc02:
>>>> import os
>>>> def run_args(arg):
> ... i, o = os.popen4('"c:/program files/test/args.bat" -vv %s' % arg)
> ... print o.read()
>>>> run_args('"this is a very long path with spaces"')
> 'c:/program' is not recognized as an internal or external command,
> operable program or batch file.
I just got the following working where os.getcwd() is returning:
'C:\\Documents and Settings\\Rob\\Desktop'
>>> def f():
... i, o = os.popen4( "\"" + os.getcwd() + "\\aaa.bat\"" )
... print o.read()
If this dosen't help, then (sound of large hammer being removed
from a tool box) maybe this will:
x = os.getcwd()
os.chdir( "c:/program files/test/" )
i, o = os.popen4( 'args.bat -vv %s' % arg )
os.chdir( x )
More information about the Python-list