简体   繁体   English

Powershell和Plink-格式化命令

[英]Powershell & Plink - formatting commands

I'm trying to push some commands to plink from within a powershell script. 我正在尝试推送一些命令以从Powershell脚本内进行链接。

I have it working, except if there is a space in the file name. 我可以正常工作,除非文件名中有空格。

$entry.name = "File with a space.txt"

$SSH_Source = "/share/USBDisk1"

$Files = $SSH_Source+$entry.Name

When I push $Files to plink it truncates after the space in the file name. 当我按下$Files进行链接时,它会在文件名中的空格后截断。

I need it to output like this with the single quotes so that plink works correctly. 我需要它以单引号输出,这样plink才能正常工作。

/share/USBDisk1/'File with a space.txt'

Thank in advance, 预先感谢,

像这样?

$entry.name = "'File with a space.txt'"

Don't you want to be doing something like: 您是否不想做类似的事情:

$entryname = "File with a space.txt"
$SSH_Source = "/share/USBDisk1"
$Files = '"' + $SSH_Source + '/' + $entryname + '"'
$Files

You want the quotes around the full path, something like: 您希望整个路径都带有引号,例如:

"/share/USBDisk1/File with a space.txt"

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM