0

Hi
I’m trying to use the function os.execv to execute a batch script within my Python script. Second argument for os.execv shall be a tuple or a list and I test to send tuple or a list as second argument, but nothing works, I get different type of error message.


mpathTotest = 'D:\projects\PythonBuild\test.bat'
argList = ("argument 1","argument 2","argument 3")
os.execv(mpathTotest, argList(1))

Erro message:
os.execv(self.mpathTotest, argList(1))
TypeError: 'tuple' object is not callable

******************************************************
argList = ["argument 1","argument 2","argument 3"]
os.execv(mpathTotest, argList[1])

Error message:
os.execv(self.mpathTotest, argList[1])
TypeError: execv() arg 2 must be a tuple or list

Anyone how has any idea about what the problem is?

3
Contributors
3
Replies
4
Views
9 Years
Discussion Span
Last Post by arkad
0

Note that argList[1] does not give list as result.
Try:
os.execv(mpathTotest, ["argument 2"])
or:
os.execv(self.mpathTotest, [argList[1]])

0

Thanks guys, I even managed to send some argument to my Batch program.


[os.execvp(pathToGet, [string, self.mPathToProject, self.mPathToSvnDir, self.mProjecName])]

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.