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

Discussion forum for all Windows batch related topics.

Moderator: DosItHelp

Post Reply
Message
Author
Technext
Posts: 13
Joined: 24 May 2010 07:42

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

#1 Post by Technext » 21 Jul 2010 14:49

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

aGerman
Expert
Posts: 4678
Joined: 22 Jan 2010 18:01
Location: Germany

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

#2 Post by aGerman » 21 Jul 2010 15:11

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

Technext
Posts: 13
Joined: 24 May 2010 07:42

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

#3 Post by Technext » 23 Jul 2010 05:55

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

Technext
Posts: 13
Joined: 24 May 2010 07:42

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

#4 Post by Technext » 25 Jul 2010 04:56

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

Post Reply