Problem with %2% as remote dir param in "synchronize" script

Advertisement

rob26
Guest

Problem with %2% as remote dir param in "synchronize" script

Using WinSCP Version 5.0.0 (Build 1431)

Here is my script:

option batch abort
option confirm off
option transfer automatic
option reconnecttime 180
option exclude "*/"
open ftps://username:password@domain -passive -implicit
synchronize remote -mirror -criteria=time %1% %2%
exit

If I execute this at commandline:
WinSCP.com /timeout=180 /script="test.txt" /parameter "C:\path" "/path"

I get this returned (note that '%2%' did not resolve):

batch abort
confirm off
transfer automatic
reconnecttime 180
exclude */
Connecting to domain ...
Connected with domain:port, negotiating SSL connection...
SSL connection established. Waiting for welcome message...
Connected
Starting the session...
Reading remote directory...
Session started.
Active session: [1] username@domain
Comparing...
Local 'C:\path' => Remote '%2%'
Error listing directory '%2%'.
Could not retrieve directory listing
CWD failed. "/%2%": directory not found.
(A)bort, (R)etry, (S)kip: Abort

If I execute this at commandline (note absence of "/" as first char of remote path):
WinSCP.com /timeout=180 /script="test.txt" /parameter "C:\path" "path"

I get this returned (note that '%2%' correctly resolved to remote 'path' this time):

batch abort
confirm off
transfer automatic
reconnecttime 180
exclude */
Connecting to domain ...
Connected with domain:port, negotiating SSL connection...
SSL connection established. Waiting for welcome message...
Connected
Starting the session...
Reading remote directory...
Session started.
Active session: [1] username@domain
Comparing...
Local 'C:\path' => Remote 'path'
Synchronizing...

It appears that "/" as first character, when within quotes as in "/path" causes the second parameter not to resolve.

Reply with quote

Advertisement

rob26
Guest

Problem with %2% as remote dir param in "synchronize" script

This problem only occurs when remote folder doesn't incude subfolders:
"/path" fails but "path" works

However:
"/path/folder" succeeds and "path/folder" fails.

Reply with quote

martin
Site Admin
martin avatar
Joined:
Posts:
40,476
Location:
Prague, Czechia

Re: Problem with %2% as remote dir param in "synchronize" script

rob26 wrote:

This problem only occurs when remote folder doesn't incude subfolders:
"/path" fails but "path" works

However:
"/path/folder" succeeds and "path/folder" fails.
Exactly. Any argument with syntax /abc is considered a switch. In this case unrecognised switch.
I have just documented how to deal with that:
https://winscp.net/eng/docs/commandline#two_slashes
Last edited by martin on 2011-09-16; edited 1 time in total

Reply with quote

Rob26
Guest

PostRe: Problem with %2% as remote dir param in "synchronize

Martin, thanks for the the clear explanation and quick response.

Reply with quote

Advertisement

You can post new topics in this forum