Plink cmd.exe mkdir with a space doesn't work

折月煮酒 提交于 2019-12-10 11:29:25

问题


I'm using plink on a windows 7 desktop to create a folder a on windows 2008 server. The server uses pragmaSSH to allow the SSH connection and everything works just fine there.

The directory I want to create has a space in it and that is where my problem starts.

I have a basic plink command that works like this

plink.exe -i privatekey.ppk user@server cmd.exe /c mkdir "c:\asdfasdf"

but changing that command to this fails. so the space is for sure my issue.

plink.exe -i privatekey.ppk user@server cmd.exe /c mkdir "c:\asdf asdf"

I've tried to escape this in every possible way I can think off and always get the same problem with the space.

Ok after 60000 tries i figured out how to pass the quotes to the server.

plink.exe -i privatekey.ppk useryserver mkdir \\"""c:\asf asf\\"""

and that sent the 1 quote on each side and ran the command as mkdir "c:\asf asf"


回答1:


The quotes are just enough to escape the command for plink which is not smart enough to quote again on the other side (reasonable, since it cannot know what weird shell might run there).

So you need the following:

plink.exe -i privatekey.ppk user@server cmd.exe /c mkdir "\"c:\asdf asdf\""


来源:https://stackoverflow.com/questions/6738038/plink-cmd-exe-mkdir-with-a-space-doesnt-work

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!