Reputation: 1708
So I'm trying to run a shell script on an automated SoapUI project which is execute in continuous integration. I need to send a few parameters and an SQL query to the script so I'm trying to execute a command similar to this:
/path/to/file.sh param1 param2 "sql query"
If I log the command and execute it manually it works perfectly but when groovy runs it the "sql query" argument is split into multiple arguments for every space.
I've tried running the command with
String command = "/path/to/file.sh param1 param2 \"sql query\""
def proc = command.execute()
proc.consumeProcessOutput(sout, serr)
proc.waitForOrKill(5000)
I'm not getting what I'm doing wrong. Best regards
Upvotes: 2
Views: 569
Reputation: 3714
In Grooy also arrays (arrays are internal lists) have a execute method. It's usually much safer to execute commands over arrays.
def command = ['/path/to/file.sh', 'param1', 'param2', 'sql query']
def proc = command.execute()
proc.consumeProcessOutput(sout, serr)
proc.waitForOrKill(5000)
Upvotes: 2