Posted 07 August 2013 - 07:33 AM
I'm using a program that can launch other programs when it receives an instruction from the main server.
To execute these programs I'm using shell.run. My problem is that I have different programs with a different number of argument, so sometimes shell.run needs 2 arguments and sometimes 3.
When the main program receives the instruction it stores the program name + parameters in a table, later it runs a function "run(table)" that receives the instruction table and runs shell.run with the arguments in the table. How do I give shell.run an unknown number of arguments from the table?
I've tried it this way but it didn't work.
To execute these programs I'm using shell.run. My problem is that I have different programs with a different number of argument, so sometimes shell.run needs 2 arguments and sometimes 3.
When the main program receives the instruction it stores the program name + parameters in a table, later it runs a function "run(table)" that receives the instruction table and runs shell.run with the arguments in the table. How do I give shell.run an unknown number of arguments from the table?
I've tried it this way but it didn't work.
function run(table)
runCommand = ""
for i,v in ipairs(table) do
if i == 1 then
runCommand = runCommand..v[1]
else
runCommand = runCommand..,..v[i]
end
end
shell.run(runCommand)
end