os.system on "program files"

CipoFuzo cipofuzo at home.com
Wed May 7 12:10:02 EDT 2003


Matt, 

Thanks for your suggestion.

This script has to be platform independent actually. I have
a config file where I can specify where the imagemagick
binaries live on linux and windows so I can execute the
correct one.

I've tried other methods of starting this process, like
os.spawnv:

>>> os.spawnv (os.P_WAIT,r'"c:\program files\imagemagick\convert.exe"', \
	('-draw',r'"-text 0 0 hello"','in.jpg','out.jpg'))

and I get the same error message. ('c:\program' is not an recognized...).
Once I take the ""s off the text argument:

>>> os.spawnv (os.P_WAIT,r'"c:\program files\imagemagick\convert.exe"', \
	('-draw',r'-text 0 0 hello','in.jpg','out.jpg'))

it executes convert.exe, nut now convert.exe has a problem with the arguments
given.

Thanks,
Cipo


In article <b9aam3$sd3$1 at slb6.atl.mindspring.net>, Matt Gerrans wrote:
>> I'm pretty sure this is a bug.
> 
> Well, "bug" is a strong word.    I've had this problem, but I just chalked
> it up to being a peculiarity of the way things are interpreted in the
> various process-starting mechanisms (comare it to the system() call in C).
> Fortunately, there are about a million different ways to start a process and
> os.system() is probably the bluntest tool in the bunch.   Check out the
> "Process Management" section of the Python Library Reference for starters.
> You seem to be running on Windows; if you don't care about platform
> independence (which I think can be assumed if you are hard-coding
> r'c:\Program Files...'), then win32.WinExec() will do your command line just
> fine and ShellExecute() or CreateProcess() can be used for fancier control.
> And you could dynamically create a shell script (or batch file as it were)
> in the temp directory and do system() on that... or...
> 
> 
> 
> 




More information about the Python-list mailing list