Why must path be in args in os.execv?

Holger Jannsen holger at phoenix-edv.netzservice.de
Wed Jun 30 16:11:28 CEST 1999


High,

there's again something I don't understand. Hope you do.;-)

I'd like to start a windows-executable with some arguments.
Ok. 'os.execv' or anything like that is the thing.

But if I don't repeat the path with the arguments, the execution fails.
Better: Something happens, but not the correct execution.

For testing I constructed an easy batch named test.bat with only one command:
echo %0 %1 %2 %3 %4 %5 >result.log

Python 1.5.2 (#0, Apr 13 1999, 10:51:12) [MSC 32 bit (Intel)] on win32
Copyright 1991-1995 Stichting Mathematisch Centrum, Amsterdam
>>> import os
>>> os.chdir("c:\\mypython")
>>> os.execv("test.bat",["test.bat","1","2","3","4"])

When I start with:
>>> os.execv("test.bat",["1","2","3","4"])
only the interpreter ends. No Log-File has been written...

I really spent a long time since I found out. Perhaps the documentation
have to be changed?
>>>
execv (path, args) 
Execute the executable path with argument list args, replacing the current process (i.e.,
the Python interpreter). The argument list may be a tuple or list of strings.
Availability: Unix, Windows. 
>>>

Ciao,
Holger




More information about the Python-list mailing list