LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Command Line arguments with spaces?

Hi,

 

I'm working on an app which can accept command line arguments. I have noticed that LV assumes everything what is separated by a space is a separate argument, so passing strings and paths are not that easy because eg 

 

path="c:\program files\test app\test.exe"

 

Is considered three separate arguments:

1: path="c:\program

2: files\test

3: app\test.exe"

 

sure its not too much of a work to write a code which takes care of this, but I'm wondering if there is an obvious workaround.

 

Thx.

0 Kudos
Message 1 of 11
(9,816 Views)

@1984 wrote:

sure its not too much of a work to write a code which takes care of this, but I'm wondering if there is an obvious workaround.


I think the obvious workaround is to write not too much code...

 

You could probably use a Windows or LabVIEW.exe API to get the command line, but that sounds like more work then e.g. a Array To Spreadsheet String...

 

 

0 Kudos
Message 2 of 11
(9,786 Views)

Try:

"executable name.exe" "path=" "c:\program files\test app\test.exe"

 

That will at least separate the command line argument into 2 items and won't break the file path at every space.

 

Also, don't forget the build spec > advanced settings "Pass all command line arguments to application".

Message 3 of 11
(9,774 Views)

An array to spreadheet achieves nothing here. You still need to determine which line belongs to which argument, which is actually easier to be done with an array.

0 Kudos
Message 4 of 11
(9,768 Views)

Thats wrong. "executable name.exe" "path=" "c:\program files\test app\test.exe" is interpreted like as three different argument:

 

1. "path="

2. "c:\program

3. files\test app\test.exe"

 

(actually it is four because the application name shows up at index 0, but that doesnt matter)

0 Kudos
Message 5 of 11
(9,766 Views)

Weird, here is the input string copied directly from my cmd line:

 

"Get LV Version.exe" "path=" "c:\program files\test app\test.exe"

 

And the output on the FP, directly from the property node:

LV_cmd_lin_args.png

 

LV 2018 SP1 f4 (32-bit) if it makes a difference.

Message 6 of 11
(9,759 Views)

Well thats definitely weird as for me all strings it break up at the spaces. I couldn't test what you suggested exactly but I have tested adding a path to the CLI in various ways but no matter what it was always ended up separated at the spaces. I'll check this tomorrow morning and get back with the result.

0 Kudos
Message 7 of 11
(9,753 Views)

It could be because your argument did not start with a quotation mark.  Try using this:

"path=c:\program files\test app\test.exe"



There are only two ways to tell somebody thanks: Kudos and Marked Solutions
Unofficial Forum Rules and Guidelines
"Not that we are sufficient in ourselves to claim anything as coming from us, but our sufficiency is from God" - 2 Corinthians 3:5
Message 8 of 11
(9,742 Views)

OK, here is the update!

 

first of all, I was wrong as 

"executable name.exe" "path=" "c:\program files\test app\test.exe"

 

actually does work. It looks pretty unnatural to provide parameters like that, but nonetheless labview breaks it apart as @playerm1 said.

 

Second:

"path=c:\program files\test app\test.exe"

 

also works, in this case the entire string counts as a single parameter. The conclusion is that if a string is in quotation marks then it is considered a single value EXCEPT if there is a string before that. So "blablabla bla bla" is one value, but --mystring="blablabla bla bla" (my original idea) is actually three as it is broken up to three pieces at the spaces.

 

So I believe the most natural CLI solution comes with combining these ideas in a form below, which looks quite standard:

 

myapp.exe --arg1 "value1 with spaces" --arg2 "value2 also with spaces"

 

Thanks for sharing your ideas, it really helped!

0 Kudos
Message 9 of 11
(9,698 Views)

@1984 wrote:

So I believe the most natural CLI solution comes with combining these ideas in a form below, which looks quite standard:

 

myapp.exe --arg1 "value1 with spaces" --arg2 "value2 also with spaces"


Yup, that looks like a standard CLI command, go with that!

G# - Award winning reference based OOP for LV, for free! - Qestit VIPM GitHub

Qestit Systems
Certified-LabVIEW-Developer
0 Kudos
Message 10 of 11
(9,693 Views)