[explained] Use of arguments (for CLI)

Things you’d like to miss in the future...
Forum rules
You might want to read this if you're looking for priority service

:info: Please Include The Following Information
1) Your XYplorer Version (e.g., v28.00.0801)
2) Your Windows Version (e.g., Win 11)
3) Your Screen Scaling Percentage (e.g., 125%).

:info: Use Your Profile Or Signature
We strongly recommend adding your Windows Version and Screen Scaling Percentage to the Location field in your Profile or to your Signature. That way, you only have to type them once, and we won't have to search for that vital information.

:info: How To Attach Images
When attaching an Image, please use the Attachment tab at the bottom of your post and click "Add files".
Post Reply
hogaty
Posts: 260
Joined: 19 Apr 2013 21:14

[explained] Use of arguments (for CLI)

Post by hogaty »

Usually there is no need to use arguments (CLI).

With use of arguments (description of strange behavior):

Command line interpreter
field executable: there is no problem, all works as expected (notepad, internet explorer,..)
field arguments: first_resolved_argument_is_not_passed <command>

example1:
field arguments: <command>
First argument <command> is not passed to application. In the case when <command> is containing space then
only part after space is passed to executable.

example2: works, but with use first_nonsense_argument only
field arguments: first_nonsense_argument <command>
First_nonsense_argument is not passed to application, <command> is passed to executable.

XYplorer 15.50.206, Windows XP SP3.

Sincerely Hogaty
Last edited by hogaty on 18 Aug 2015 10:57, edited 1 time in total.

highend
Posts: 15016
Joined: 06 Feb 2011 00:33
Location: Win Server 2022 @100%

Re: Use of arguments (for CLI)

Post by highend »

First argument <command> is not passed to application. In the case when <command> is containing space then
only part after space is passed to executable.
Em, quote it correctly?

Never had any problems with command line parameters with XY.

Any real world example where it's failing?
One of my scripts helped you out? Please donate via Paypal

Stef123

Re: Use of arguments (for CLI)

Post by Stef123 »

I've been struggling with this ever since using XY for the first time, with various ups and downs. You'll find numerous help topics for this, such as http://www.xyplorer.com/xyfc/viewtopic. ... 846#p40846

And yet, I ran into problems all over again. My current guidelines have not let me down yet - knock on wood:
  1. Put every component in it's own pair of dual ""double quotes"", no matter how short, no matter whether it contains spaces or not. It may look silly, but do it anyway.
  2. Do not apply step 1 from above if the component qualifies as a parameter. It's my step 2, because I actually remove them, I find it easier to first see all ""components"" clearly seperated, then decide what qualifies as parameters. Never put parameters inside quotes.
  3. Frame the whole thing in one set of "double quotes" - but leave <run> and <;> outside the frame
  4. Frame variables in single 'quotes' when you don't want XY parameters resolved but rendered literally.
Example:

Code: Select all

run """cmd"" /c ""D:\nconvert.exe"" -o ""U:\$NameNew#.jpg"" -resize 1920 0 ""$item""";

highend
Posts: 15016
Joined: 06 Feb 2011 00:33
Location: Win Server 2022 @100%

Re: Use of arguments (for CLI)

Post by highend »

Stef,

why do you run the cmd in front of nconvert? Unnecessary, nconvert by itself is already a command line tool.

Code: Select all

run """D:\nconvert.exe"" -o ""U:\$NameNew#.jpg"" -resize 1920 0 ""$item""";
is absolutely enough :)
One of my scripts helped you out? Please donate via Paypal

Stef123

Re: Use of arguments (for CLI)

Post by Stef123 »

I simplified it to not make it look even more complicated. The real thing requires it or it won't work.
Besides, it serves as my instruction guideline - meant to also cover cases that - unlike my example here - may cause misbehavings. My goal was a catch-all instruction, the ones I had read elsewhere always failed me in some cases, I wanted to get a foolproof method, once and for all.

FYI - my example is a spin-off from the one you helped me out with - you suggested the dual dbl quotes around ""cmd"" which does work indeed, whereas a simple cmd won't do the trick. Cmd is necessary because the real thing starts like this

Code: Select all

runret("""cmd"" /c ...
And again - it won't work if you leave out the dual set around ""cmd"" - you figured it out eventually. I figured it is good to know about this. Thinking you only need to quote parts with spaces in them doesn't really cut it, too many exceptions.

hogaty
Posts: 260
Joined: 19 Apr 2013 21:14

Re: Use of arguments (for CLI)

Post by hogaty »

Hello

I have described problems related to command line interpreter (GUI configuration of CLI, Tools->Configuration->Colors and Styles->Templates->Command Line Interpreter), namely:

First argument entered into field arguments: is not passed to executable. The First argument is always skipped. Second argument is first argument passed to executable..

I apologize for insufficient description.

Sincerely Hogaty

hogaty wrote:Usually there is no need to use arguments (CLI).

With use of arguments (description of strange behavior):

Command line interpreter
field executable: there is no problem, all works as expected (notepad, internet explorer,..)
field arguments: first_resolved_argument_is_not_passed <command>

example1:
field arguments: <command>
First argument <command> is not passed to application. In the case when <command> is containing space then
only part after space is passed to executable.

example2: works, but with use first_nonsense_argument only
field arguments: first_nonsense_argument <command>
First_nonsense_argument is not passed to application, <command> is passed to executable.

XYplorer 15.50.206, Windows XP SP3.

Sincerely Hogaty

highend
Posts: 15016
Joined: 06 Feb 2011 00:33
Location: Win Server 2022 @100%

Re: Use of arguments (for CLI)

Post by highend »

Tools->Configuration->Colors and Styles->Templates->Command Line Interpreter
Screenshot of that setting...
One of my scripts helped you out? Please donate via Paypal

hogaty
Posts: 260
Joined: 19 Apr 2013 21:14

Re: Use of arguments (for CLI)

Post by hogaty »

Attachment CLI_settings.gif

Content of address bar is:
!www.paypal.com

Hogaty
highend wrote:
Tools->Configuration->Colors and Styles->Templates->Command Line Interpreter
Screenshot of that setting...
To see the attached files, you need to log into the forum.

highend
Posts: 15016
Joined: 06 Feb 2011 00:33
Location: Win Server 2022 @100%

Re: Use of arguments (for CLI)

Post by highend »

WTF?

This setting is meant for the command line interpreter, not for any "normal" application...

Don't know if the arguments field accepts any parameters for other applications...
One of my scripts helped you out? Please donate via Paypal

hogaty
Posts: 260
Joined: 19 Apr 2013 21:14

Re: Use of arguments (for CLI)

Post by hogaty »

Well, it works as expected for CLI C:\Windows\System32\cmd.exe.
Field Arguments must be leaved empty or must contain: /K <command>
But some member of Xyplorer forum had described use C:\Windows\System32\notepad.exe
which was entered into field executable instead a CLI.
Notepad.exe works with empty field Arguments or with <comspec> entered as second
parameter into Field arguments. First parameter in field arguments is skipped.

Conclusion:
Use of executables other than CLI instead CLI ,is unsupported. But in fact it can
somehow work.

Hogaty
highend wrote:WTF?

This setting is meant for the command line interpreter, not for any "normal" application...

Don't know if the arguments field accepts any parameters for other applications...

bdeshi
Posts: 4256
Joined: 12 Mar 2014 17:27
Location: Asteroid B-612
Contact:

Re: [explained] Use of arguments (for CLI)

Post by bdeshi »

You can use an alias (read help) to open URL from the addressbar when you also need to pass custom cmd args.

But you can already open an URL by typing it's address directly, just include the protocol prefix: https:// etc.
Icon Names | Onyx | Undocumented Commands | xypcre
[ this user is asleep ]

Post Reply