I have a C++ Visual Studio program called Test which takes two arguments. I have to run this program with large number of different arguments like:
- ./test -a -b (a is arg1, b is arg2)
- ./test -c -d
- .
- .
- .
How can I create a python script which runs this program multiple times if I provide the set of arguments? (instead of me running the above command multiple times).
Soln: This is the code I used:
for commands in listargs:
cmd = ["../../Test.exe", commands[0], commands[1]]
result = subprocess.Popen(cmd, stdout=subprocess.PIPE)
stdin, stderr = result.communicate()
print stdin
I am giving the arguments in a list of 2-member tuples(listargs). Each tuple has the arguments for one execution. Or as abernet mentioned, we can give arguments in csv file. Thanks for helping me.
aandbat a prompt? Or create a CSV file with rows likea,b? Or …?