Forum Discussion

tessem's avatar
13 years ago

Dual space are trimmed

Have anyone here tried to run ProcessRunner where the arguments contains more than one space?
Don't know if this should be defined as a LoadUI bug or as a Groovy "feature", but this is my situation:
Trying to run
c:\temp\my.exe -t "xyz:1 2  3"

is treated as
c:\temp\my.exe -t "xyz:1 2 3"


Do you know a workaround ??

1 Reply

  • SmartBear_Suppo's avatar
    SmartBear_Suppo
    SmartBear Alumni (Retired)
    Hi,

    After some poking around I've found that this is actually a "feature" in Java. Specifically the Runtime.exec() method. Most ways of calling this, including the way Groovy does, has the issue you're experiencing. However, by giving the command as an array of Strings instead of a single String this can be avoided (the problem lies in Javas way of splitting the command string into subparts), so potentially the Process Runner component could be rewritten to avoid this. What needs to be changed is essentially this:


    def commandString = "c:\temp\my.exe -t \"xyz:1 2 3\""
    def proc = commandString.exec()


    to


    def commandArray = [ "c:\temp\my.exe", "-t", "\"xyz:1 2 3\"" ]
    def proc = Runtime.runtime.exec( commandArray )


    Feel free to give this a shot yourself by editing ProcessRunner.groovy. I can't say for sure if/when we'll get around to adding this ourselves.

    Regards,
    Dain
    SmartBear Software