Python: Passing arguments when running an external command -


i calling external program

call(["./myprogram", myargs]) 

how can pass list of arguments? myprogram takes 3 parameters this

myprogram param1 param2 param3 

specifiying arguments seperately below works

call(["./myprogram", param1 ,param2, param3]) 

, how can use list/array of arguments, like

myargs=[param1,param2,param3] 

i getting this

traceback (most recent call last): file "<stdin>", line 1, in <module> file "/usr/lib/python2.7/subprocess.py", line 493, in call return popen(*popenargs, **kwargs).wait() file "/usr/lib/python2.7/subprocess.py", line 679, in __init__errread, errwrite) file "/usr/lib/python2.7/subprocess.py", line 1249, in _execute_child raise child_exception typeerror: execv() arg 2 must contain strings 

just concatenate lists:

call(['./myprogram'] + myargs) 

the first argument must list of strings; build list 2 separate lists.


Comments

Popular posts from this blog

java.util.scanner - How to read and add only numbers to array from a text file -

rewrite - Trouble with Wordpress multiple custom querystrings -