Exec command problem

Queries related to T-Plan Robot
Post Reply
Justin
User
User
Posts: 7
Joined: Tue Sep 27, 2011 12:13 am
First Name: Justin
Last Name: Sketchley
Company: Gemini

Exec command problem

Post by Justin » Thu Oct 20, 2011 9:21 pm

I can't get the exec command to work properly when the paths to files include spaces. I am on a Mac OSX 10.6.8.

I run the command:

Exec "diff \"{_ENV_VARIABLE}/Data/file name.txt\" \"{_ENV_VARIABLE}/Results/file name.txt\""

And I get this exec_error:

diff: extra operand `"/path1/path2/Results/file' diff: Try `diff --help' for more information.

the exec_command looks like this:

diff "/path1/path2/Data/file name.txt" "/path1/path2/Results/file name.txt"

Putting the above commmand in the console works fine, so it must be a problem with the exec command.


I have also tried
String replace "file name.txt" pattern="\s" replacement="\\ " but that doesn't work either, even with the exec command looking like:

diff /path1/path2/Data/file\ name.txt /path1/path2/Results/file\ name.txt

rpes
User
User
Posts: 74
Joined: Thu Oct 29, 2009 5:43 pm
First Name: Robert
Last Name: Pes
Company: T-Plan

Re: Exec command problem

Post by rpes » Fri Oct 21, 2011 8:32 am

I retested a similar command on a Mac OS environment and I can reproduce the issue. A short web research reveals that this is a known issue of Java on Mac OS which fails to parse the command arguments containing spaces correctly.

Though this problem can't be worked around from a test script, one of the web resources suggests a way to fix this behavior at the level of the T-Plan Robot source code. The trick is to make the Exec command parse the input command on its own and pass it to the OS in form of an array. I will implement it today and I'll release a new 2.3.4Beta if it works properly. Stay tuned for updates.

rpes
User
User
Posts: 74
Joined: Thu Oct 29, 2009 5:43 pm
First Name: Robert
Last Name: Pes
Company: T-Plan

Re: Exec command problem

Post by rpes » Fri Oct 21, 2011 7:12 pm

The issue is resolved in the latest 2.3.4Beta release. You may get it through the Tools->Update & Upgrade window. If you don't see the build make sure to select the Preferences button and set off hiding of unstable releases.

According to my research, Mac OS X supports just like any other Linux/Unix system three ways of handling of spaces in the command name and/or its arguments:

* Enclosing with double quotes (")
* Enclosing with single quotes (")
* Escaping of the space character(s) with a backslash (\)

The Exec command calling a "diff" comparing two files containing spaces can be then specified in one of the following ways:

Exec "diff \"/tmp/text 1.txt\" \"/tmp/text 2.txt\""
Exec "diff '/tmp/text 1.txt' '/tmp/text 2.txt'"
Exec "diff /tmp/text\ 1.txt /tmp/text\ 2.txt"

I have verified that all three ways work fine with the specified build on the Mac OS environment.

Justin
User
User
Posts: 7
Joined: Tue Sep 27, 2011 12:13 am
First Name: Justin
Last Name: Sketchley
Company: Gemini

Re: Exec command problem

Post by Justin » Fri Oct 21, 2011 10:33 pm

Okay sweet. Everything works now.

Post Reply

Who is online

Users browsing this forum: No registered users and 1 guest