Long UNC path not working in CMD.EXE

July 23, 2010 at 07:12:04
Specs: Windows

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,
Plink -ssh -pw xxx user@server cmd.exe /c copy //test//somedir//inside//some.exe //test//another//

Not Working:
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').

[By the way, the double forward slashes work with Plink tool.]

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?


See More: Long UNC path not working in CMD.EXE

Report •

July 25, 2010 at 03:59:24
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.

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.

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?


Report •
Related Solutions

Ask Question