Page 1 of 1

Long UNC path not working in CMD.EXE on remote machine

Posted: 21 Jul 2010 14:49
by Technext
Hi,


I am trying to connect to a remote server using Plink tool. Both my local and remote machines are Windows. On remote server, I have OpenSSH server installed. I am able to run commands on remote machine but there is some problem with long UNC path, which I noticed today.

For example,
--------------------------------------------------------------
Working:

Code: Select all

Plink -ssh -pw xxx user@server cmd.exe /c copy //test//somedir//inside//some.exe //test//another//

Not Working:

Code: Select all

Plink -ssh -pw xxx user@server cmd.exe /c copy //test//somedir//inside//more//prog.exe //test//another//

When I did echo to see how it's interpreting the command, I saw the following output:
.....//test//somedir//inside//mo //test//another//

As you can see above, it's not working if the sub-directory level increases above 2. It just prints the first two characters of the third directory (here 'mo' for directory name 'more').
--------------------------------------------------------------

This doesn't look like the 8-character DOS issue because the real path that I am using has the first directory containing 11 characters. I am not sure whether it's a limitation of Plink tool or command shell or something else.

By the way, my script takes the UNC path as input from the user. It can contain any no. of sub-directory levels. I think it should not exceed more than 8-9 levels in any normal case but it'll be better if the solution works for any arbitrary levels.

I have thought of mapping the UNC path to some drive letter but I want to explore some other alternative (short & sweet). I think, implementing mapping might involve a good deal of work.

Can anyone suggest a way to overcome this problem?


Thanks,
GC

Re: Long UNC path not working in CMD.EXE on remote machine

Posted: 21 Jul 2010 15:11
by aGerman
Sounds like a limit of Plink.
Did you try to exchange double slashes by a back slash?

Code: Select all

set path1=//test//somedir//inside//more//prog.exe
set path2=//test//another//

set "path1=%path1://=\%"
set "path2=%path2://=\%"

Plink -ssh -pw xxx user@server cmd.exe /c copy %path1% %path2%


Regards
aGerman

Re: Long UNC path not working in CMD.EXE on remote machine

Posted: 23 Jul 2010 05:55
by Technext
Thanks for your reply but this is not working. Plink works fine with double forward slashes.

I don't think it's an issue with the slashes.

Regards,
GC

Re: Long UNC path not working in CMD.EXE on remote machine

Posted: 25 Jul 2010 04:56
by Technext
I was trying to see whether mapping the UNC path to a drive letter on the same machine (where UNC is pointing to) works. I tried using SUBST command for the same, but to no avail. I do not get any error message after I execute the command but when I check the remote server, I am not able to see the virtual drive that I assigned to the UNC path.

Code: Select all

plink -ssh -pw xxx admin@server cmd.exe /c subst v: '\\\server\use'
[Ignore the triple slashes; they work with Plink.]

I also tried using the actual path, but again it did not work.

Code: Select all

plink -ssh -pw xxx admin@server cmd.exe /c subst v: 'H:\use'

After I run the above command, I cannot see v: drive on the server.

Any pointers/help?


Regards,
GC