groovy execute with parameters containing spaces

Sorry man, none of the tricks above worked for me. This piece of horrible code is the only thing that went thru:

    def command = 'bash ~my_app/bin/job-runner.sh -n " MyJob today_date=20130202 " ' 
    File file = new File("hello.sh")
    file.delete()       
    file << ("#!/bin/bash\n")
    file << (command)
    def proc = "bash hello.sh".execute()                 // Call *execute* on the file

The trick was to use a list:

println(['ls', '/tmp/folder with spaces'].execute().text)

One weird trick for people who need regular quotes processing, pipes etc: use bash -c

['bash','-c',
'''
docker container ls --format="{{.ID}}" | xargs -n1 docker container inspect --format='{{.ID}} {{.State.StartedAt}}' | sort -k2,1
'''].execute().text

Tags:

Groovy