Topic "Issue with passing command line parameter (path) with space"

Author Message
Carmageddon
[View user's profile]

Joined: 2010-01-26
Posts: 4
Location: Israel
Hi, I am developing tools for our company's server farm monitoring - to ease the job of the operators.

One of the things we need to do sometimes, is retrieve the certain event logs from servers.
So far people would use WinSCP manually.

I am trying to get them now automatically via JavaScript with just single click from web status monitoring page, something like this:

C:\Program Files\WinSCP>winscp.exe /ini=C:\WinSCP.ini" SessionName1 /console /command "cd /home/username1/logs/uut/MN00093\IVT Gen2" "get event* c:\tmp"

Then, in the command line window, I get something like:
Too many parameters for the command 'cd'.
And of course, then it would (or would not..) copy entirely different files since it didnt change to the folder with space in it...

I haev tried everything I could think of... I tried doing "\ " to escape the space, I tried the web standard of %20 - nothing works.

WinSCP version is 4.1.8 build 415.

Is there a workaround to this? if not this really needs some fix please.. asap Smile

Also - one more question please: how do I specify actions other than the /defaults parameter? so I can customize the actions via the command line parameters too Smile



Thanks!
Advertisements
martin
[View user's profile]
Site Admin
Joined: 2002-12-10
Posts: 25015
Location: Prague, Czechia
Please read documentation. If that does not help, come back.

Quote:
Also - one more question please: how do I specify actions other than the /defaults parameter? so I can customize the actions via the command line parameters too Smile

I do not understand. Give me an example of what you are trying to do.
_________________
Martin Prikryl
Carmageddon
[View user's profile]

Joined: 2010-01-26
Posts: 4
Location: Israel
prikryl wrote:
Please read documentation. If that does not help, come back.

Quote:
Also - one more question please: how do I specify actions other than the /defaults parameter? so I can customize the actions via the command line parameters too Smile

I do not understand. Give me an example of what you are trying to do.


Apologies for the late reply.

From the documentation:
Quote:
Command parameters that include space(s) have to be enclosed in double-quotes....
Code:
put "file with spaces and ""quotes"".html"


However, this is good for running a static SCRIPT file, not for when I try to use command line parameters using the /command parameter to RUN the application in /console mode.

I however went ahead and tried out like in the instructions example (note the extra quotes for the path inside cd command):
C:\Program Files\WinSCP>winscp.exe /ini=C:\WinSCP.ini" SessionName1 /console /command "cd "/home/username1/logs/uut/MN00093\IVT Gen2"" "get event* c:\tmp"

I get this error in the running console:
Error changing directory to '/home/username1/logs/uut/MN00093\IVT'.
Cannot get real path for '/home/username1/logs/uut/MN00093\IVT'.

So, seems there is nothing documented for spaces passed inside a PARAMETER to the application(not in a script!).
Any other suggestions?



Regarding the bit about /defaults - what I mean is, if I for example use /synchronize parameter - if I dont specify the /default parameter, its gonna ask the user, whether I want to port to local, remote, which files to overwrite etc.
Is there a way to specify all these options manually in command line parameters? other than /defaults?

I hope now you understand, what I am trying to accomplish Smile
martin
[View user's profile]
Site Admin
Joined: 2002-12-10
Posts: 25015
Location: Prague, Czechia
Carmageddon wrote:
So, seems there is nothing documented for spaces passed inside a PARAMETER to the application(not in a script!).

It is the same:
winscp.exe /ini=C:\WinSCP.ini" SessionName1 /console /command "cd ""/home/username1/logs/uut/MN00093\IVT Gen2""" "get event* c:\tmp"

Quote:
Regarding the bit about /defaults - what I mean is, if I for example use /synchronize parameter - if I dont specify the /default parameter, its gonna ask the user, whether I want to port to local, remote, which files to overwrite etc.
Is there a way to specify all these options manually in command line parameters? other than /defaults?

No. But you can run WinSCP with custom INI file with your prefrences.
_________________
Martin Prikryl
Carmageddon
[View user's profile]

Joined: 2010-01-26
Posts: 4
Location: Israel
prikryl wrote:
Carmageddon wrote:
So, seems there is nothing documented for spaces passed inside a PARAMETER to the application(not in a script!).

It is the same:
winscp.exe /ini=C:\WinSCP.ini" SessionName1 /console /command "cd ""/home/username1/logs/uut/MN00093\IVT Gen2""" "get event* c:\tmp"

Quote:
Regarding the bit about /defaults - what I mean is, if I for example use /synchronize parameter - if I dont specify the /default parameter, its gonna ask the user, whether I want to port to local, remote, which files to overwrite etc.
Is there a way to specify all these options manually in command line parameters? other than /defaults?

No. But you can run WinSCP with custom INI file with your prefrences.


Thank you! it works indeed Smile
I still dont quite get why this works though, because the double-double quotes (according to the documetnation), are designed to escape a quotation character(use literally) - at least according to the explanation.

So, you might want to update the documentation along with an example, as this bit isnt quite clear:

Quote:
Command parameters that include space(s) have to be enclosed in double-quotes. To use double-quote literally, double it:

Should be:
Quote:
Command parameters that include space(s) have to be enclosed in DOUBLE-double-quotes. To use double-quote literally, double it:


And the example
Quote:
put "file with spaces and ""quotes"".html"

Needs to be:
Quote:
put ""file with spaces and ""quotes"".html""


At least that is the way you fixed the example in my case, and which actually works for me.

Again, thank you!
martin
[View user's profile]
Site Admin
Joined: 2002-12-10
Posts: 25015
Location: Prague, Czechia
Carmageddon wrote:
I still dont quite get why this works though, because the double-double quotes (according to the documetnation), are designed to escape a quotation character(use literally) - at least according to the explanation.

The double-double-quoting here is because of the command-line not because of the script, what the documentation refers to. This is not documented, but the behaviour is identical to the double-double-quoting in the script file. So the actual script command does not have any double-double quotes. If it had, there would had to be quad-double-quotes on the command line.
_________________
Martin Prikryl
martin
[View user's profile]
Site Admin
Joined: 2002-12-10
Posts: 25015
Location: Prague, Czechia
I have documented doubling double-quotes on command-line.
Advertisements

You can post new topics in this forum






Search Site

What is WinSCP?

It is award-winning SFTP client, SCP client, FTPS client and FTP client integrated into one software program for file transfer to FTP server or secure SFTP server. [More]

And it's free!

Donate

About donations

$9   $19   $49   $99

About donations

Recommend

WinSCP Privacy Policy

WinSCP License