Why must path be in args in os.execv?

Holger Jannsen Holger.Jannsen at p98.f112.n480.z2.fidonet.org
Wed Jun 30 10:11:28 EDT 1999


From: Holger Jannsen <holger at phoenix-edv.netzservice.de>

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