问题
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