groovy - Why won't ArrayList.execute() use given arguments? -


i'm trying run batch script on windows using groovy. started code:

stringbuilder output = new stringbuilder() stringbuilder error = new stringbuilder() dir = new file("$homedir") process proc = "pathtoscript\script.bat --arg test".execute(null, dir) proc.consumeprocessoutput(output, error) proc.waitfor() print proc.exitvalue() 

this code works fine scripts, commands don't play nice, decided start using arraylist store arguments. code looks this:

stringbuilder output = new stringbuilder() stringbuilder error = new stringbuilder() dir = new file("$homedir") arraylist command = ["pathtoscript\script.bat", "--arg test"] process proc = command.execute(null, dir) proc.consumeprocessoutput(output, error) proc.waitfor() print proc.exitvalue() 

now inexplicable reason runs script.bat without arguments. i've printed out list sure contains arguments properly, does, i'm not sure why execute method isn't using them.

try:

arraylist command = ["pathtoscript\script.bat", "--arg", "test"] 

when instance of list used source execute() arguments should passed separately.


Comments