带空格的 Plink cmd.exe mkdir 不起作用
我在 Windows 7 桌面上使用 plink
在 Windows 2008 服务器上创建文件夹 a。 服务器使用 pragmaSSH 来允许 SSH 连接,并且一切正常。
我要创建的目录中有一个空格,这就是我的问题开始的地方。
我有一个基本的 plink
命令,其工作原理与此类似
plink.exe -i privatekey.ppk user@server cmd.exe /c mkdir "c:\asdfasdf"
,但将该命令更改为此失败。所以空间肯定是我的问题。
plink.exe -i privatekey.ppk user@server cmd.exe /c mkdir "c:\asdf asdf"
我试图用我能想到的一切可能的方式来逃避这个问题,但总是在空间上遇到同样的问题。
好吧,经过 60000 次尝试,我弄清楚了如何将引号传递到服务器。
plink.exe -i privatekey.ppk useryserver mkdir \\"""c:\asf asf\\"""
并在每一侧发送 1 个引号并将命令运行为 mkdir "c:\asf asf"
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"
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
引号足以转义
plink
命令,该命令不够智能,无法在另一端再次引用(合理,因为它不知道那里可能运行什么奇怪的 shell)。所以你需要以下内容:
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: