在某些服务器中,变量$cygwin_folder
可以不同。但是由于某种原因,它并没有扩大。也许是由于斜杠c:\$cygwin_folder
引起的,但我不确定如何解决此问题?
c:\$cygwin_folder\bin\bash.exe -c some_command
代码如下:
if(test-path("c:\cygwin")) {
$cygwin_folder = "cygwin";
}
ElseIF (test-path("c:\cygwin64")) {
$cygwin_folder = "cygwin64";
}
Else {
echo "Cygwin directory not found";
exit
}
c:\$cygwin_folder\bin\bash.exe -c some_command
错误:
c:\$cygwin_folder\bin\bash.exe : The term 'c:\$cygwin_folder\bin\bash.exe' is not recognized as the name of a cmdlet,
function, script file, or operable program. Check the spelling of the name, or if a path was included, verify that the path
is correct and try again.
At C:\Program Files\zabbix\userparams\myscript.ps1:79 char:1
+ c:\$cygwin_folder\bin\bash.exe -c ("/usr/bin/scp -o StrictHostKeyChecking=no -o ...
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : ObjectNotFound: (c:\$cygwin_folder\bin\bash.exe:String) [], CommandNotFoundException
+ FullyQualifiedErrorId : CommandNotFoundException
答案 0 :(得分:5)
隐式字符串扩展仅适用于参数参数,请使用Promise.all()
调用运算符将扩展字符串作为命令来调用:
&