开发者

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

I'm using plink on a windows 7 desktop to create a folder a on win开发者_Python百科dows 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"


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\""
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜