UNC path with blank spaces

Advertisement

me119394
Joined:
Posts:
5
Location:
London

UNC path with blank spaces

Hi,

I am using version 4.1.8 and have got a wise script which runs an automated file upload however I'm having an issue with the UNC path having a blank space ie "D:\Test\BOXIT\my[space]test\more[space]test\test"

This is the script:

Set Variable
Variable=WINSCP
Value=c:\Program Files\WinSCP\winscp.exe
end
Set Variable
Variable=FILELOC1
Value=""""D:\Test\BOXIT\my test\more test\test""""
end
Set Variable
Variable=PASS
Value=XXXXXXXXXXXX
end
Execute Program
Pathname=%WINSCP%
Command Line=/console /command "open XXXX\%PASS%" "option confirm off" "put %FILELOC1%\ /XXXX/XXXXX/Test" "exit"
Flags=00000010
end
I have tried the normal thing of using double quotes and even double double quotes but keeps erroring with the following:

[i][i]Searching for host...
Connecting to host...
Authenticating...
Using username "XXXXX\XXXXX".
Authenticating with pre-entered password.
Authenticated.
Starting the session...
Reading remote directory...
Session started.
Active session: [1] XXXXX\XXXXX@ftp.XXXXX.co.uk
confirm off
D:\Test\BOXIT\my | 0 KiB | 0.0 KiB/s | binary | 0%
File or folder 'D:\Test\BOXIT\my' does not exist.
System Error. Code: 2.
The system cannot find the file specified
(A)bort, (R)etry, (S)kip, Ski(p) all:
[/i][/i]


As you can see it breaks the path at the blank space and errors.
Although we get round the issue by creating a static drive mapping that however requires a user account to be logged on 24x7, unfortunately when the machine is rebooted and the account is not logged back on, the automated script fails as it can no longer see the static drive mapping.
Any help would be greatly appreciated.

Reply with quote

Advertisement

martin
Site Admin
martin avatar
Joined:
Posts:
41,454
Location:
Prague, Czechia

Re: UNC path with blank spaces

I do not know how you script language deals with quotes, so I do not know what's actual input into WinSCP. Though I won't work anyway, unless you use WinSCP 4.2.5.

Reply with quote

me119394
Joined:
Posts:
5
Location:
London

I have upgraded to version 4.2.5 and it still does not work.
I don't agree that it's the script that's at fault because all that is doing is mimicing commandline instructions. In most programs double quotes " " are added at the start and end of a UNC path which contains a blank space so it is seen as a single string, however WinSCP does not appear to be able to handle this kind of UNC path (albeit very commonly used in directory names).
ie In a command Prompt, if you wanted to change the directory from C:\ to the Winscp folder you have to send the following command cd "Program files\Winscp" the use of the double quotes because of the blank space in the Program Files directory.
Even if I run this commandline manually from a command prompt

C:\Program Files\WinSCP>winscp.exe /console /command "open bXXXX\BXXXX:HXXXXX@f
tp.bXXXX.co.uk" "option confirm off" "put D:\Test\BXXXX\my test\more test\test\ /Home/bXXX-BXXX/Test"
"exit"


I still get the same following error

Searching for host...
Connecting to host...
Authenticating...
Using username "bXXXX\BXXXX".
Authenticating with pre-entered password.
Authenticated.
Starting the session...
Reading remote directory...
Session started.
Active session: [1] bXXXX\BXXXX@ftp.XXXX.co.uk
confirm off
File or folder 'D:\Test\BOXIT\my' does not exist.
System Error. Code: 2.
The system cannot find the file specified
(A)bort, (R)etry, (S)kip, Ski(p) all:


It does appear that WinSCP is unable to handle UNC paths with blank spaces, unless it works in a different way in which another kind of annotation is used so the path is seen as a full string instead of broken paths by the blank spaces.
Is this a bug in the program...?

Reply with quote

martin
Site Admin
martin avatar
Joined:
Posts:
41,454
Location:
Prague, Czechia

me119394 wrote:

C:\Program Files\WinSCP>winscp.exe /console /command "open bXXXX\BXXXX:HXXXXX@f
tp.bXXXX.co.uk" "option confirm off" "put D:\Test\BXXXX\my test\more test\test\ /Home/bXXX-BXXX/Test"
"exit"
I do not see any double quotes around path in your command. This should work:
C:\Program Files\WinSCP>winscp.exe /console /command "open bXXXX\BXXXX:HXXXXX@f
tp.bXXXX.co.uk" "option confirm off" "put ""D:\Test\BXXXX\my test\more test\test\"" /Home/bXXX-BXXX/Test"
"exit"

Reply with quote

me119394

That worked, that's for your help and I realise that is actually our fault and we should have spotted that the quotes were missing from the UNC path.

Regards

Reply with quote

Advertisement

You can post new topics in this forum