引用 windows 路径字符串中的属性
referencing an attribute in a windows path string
我在 chef 中执行了以下命令:
#execute
execute 'service-api install' do
command 'c:\buildinfo\service-api\api\approot\web-#{node['default']['env']}.cmd'
end
its 运行ning in windows and #{node['default']['env']} 是我试图在路径字符串中引用的属性多于。
当我 运行 时,出现以下错误:
> SyntaxError
> ==> default: -----------
> ==> default: C:\vagrant-chef9622f1791bb50a8f9441fd4c1ff806\cookbooks\djcm_paypal_win\recipes\installService.rb:76:
> syntax error, unexpected tIDENTIFIER, expecting keyword_end
> ==> default: ...api\approot\web-#{node['default']['env']}.cmd'
如果我尝试:
#execute
execute 'service-api install' do
command "c:\buildinfo\service-api\api\approot\web-#{node['default']['env']}.cmd"
end
斜线以不同的颜色显示(转义字符?)并且出现以下错误:
[execute] The filename, directory name, or volume label syntax is incorrect.
command "c:\buildinfo ervice-api\api\approotweb-integration.cmd"
所以它在斜杠周围弄乱了但得到了属性。如何在带斜杠的字符串中指定属性?
编辑 1:
我尝试了双斜杠和其他解决方案,即使它现在试图找到正确的路径但仍然会失败,即使文件存在于那个确切的位置并且我可以手动 运行 它。有什么想法吗?
现在的错误:
* execute[service-api install] action run
==> default: [execute] The system cannot find the path specified.
==> default:
==> default:
==> default: ================================================================================
==> default: Error executing action `run` on resource 'execute[service-api install]'
==> default: ================================================================================
==> default:
==> default: Mixlib::ShellOut::ShellCommandFailed
==> default: ------------------------------------
==> default: Expected process to exit with [0], but received '1'
==> default: ---- Begin output of c:\buildinfo\service-api\api\approot\web-integration.cmd ----
==> default: STDOUT:
==> default: STDERR: The system cannot find the path specified.
==> default: ---- End output of c:\buildinfo\service-api\api\approot\web-integration.cmd ----
==> default: Ran c:\buildinfo\service-api\api\approot\web-integration.cmd returned 1
使用单引号将不允许插值。使用双引号会使反斜杠有特殊意义,所以\b
means "backspace".
您可以妥协,使用 %
运算符添加内容 printf
-style:
command('c:\buildinfo\service-api\api\approot\web-%s.cmd' % node['default']['env'])
我在 chef 中执行了以下命令:
#execute
execute 'service-api install' do
command 'c:\buildinfo\service-api\api\approot\web-#{node['default']['env']}.cmd'
end
its 运行ning in windows and #{node['default']['env']} 是我试图在路径字符串中引用的属性多于。
当我 运行 时,出现以下错误:
> SyntaxError
> ==> default: -----------
> ==> default: C:\vagrant-chef9622f1791bb50a8f9441fd4c1ff806\cookbooks\djcm_paypal_win\recipes\installService.rb:76:
> syntax error, unexpected tIDENTIFIER, expecting keyword_end
> ==> default: ...api\approot\web-#{node['default']['env']}.cmd'
如果我尝试:
#execute
execute 'service-api install' do
command "c:\buildinfo\service-api\api\approot\web-#{node['default']['env']}.cmd"
end
斜线以不同的颜色显示(转义字符?)并且出现以下错误:
[execute] The filename, directory name, or volume label syntax is incorrect.
command "c:\buildinfo ervice-api\api\approotweb-integration.cmd"
所以它在斜杠周围弄乱了但得到了属性。如何在带斜杠的字符串中指定属性?
编辑 1: 我尝试了双斜杠和其他解决方案,即使它现在试图找到正确的路径但仍然会失败,即使文件存在于那个确切的位置并且我可以手动 运行 它。有什么想法吗?
现在的错误:
* execute[service-api install] action run
==> default: [execute] The system cannot find the path specified.
==> default:
==> default:
==> default: ================================================================================
==> default: Error executing action `run` on resource 'execute[service-api install]'
==> default: ================================================================================
==> default:
==> default: Mixlib::ShellOut::ShellCommandFailed
==> default: ------------------------------------
==> default: Expected process to exit with [0], but received '1'
==> default: ---- Begin output of c:\buildinfo\service-api\api\approot\web-integration.cmd ----
==> default: STDOUT:
==> default: STDERR: The system cannot find the path specified.
==> default: ---- End output of c:\buildinfo\service-api\api\approot\web-integration.cmd ----
==> default: Ran c:\buildinfo\service-api\api\approot\web-integration.cmd returned 1
使用单引号将不允许插值。使用双引号会使反斜杠有特殊意义,所以\b
means "backspace".
您可以妥协,使用 %
运算符添加内容 printf
-style:
command('c:\buildinfo\service-api\api\approot\web-%s.cmd' % node['default']['env'])