2014-12-04 161 views
0

我正在寫一個非常基本的配方,將數據從一個文件夾複製到另一個文件夾。我寫了下面的代碼:廚師執行資源拋出錯誤

執行 「file_sharing」 做

命令 「複製 」X:\ B2BPortal-0.0.1-SNAPSHOT.war「」 C:\ Apache的Tomcat的6.0.32 \阿帕奇-tomcat-6.0.32 \ webapps「;/Y;」

當我去我的節點,並嘗試執行該命令,它運行完全正常。但是如果我嘗試通過廚師來運行這個配方,那就是拋出錯誤。附上錯誤的屏幕截圖。請看看,並提出解決方案。![錯誤

command "copy "X:\B2BPortal-0.0.1-SNAPSHOT.wa... 
 
       ^
 
c:/chef/cache/cookbooks/file_sharing/recipes/default.rb:11: no .<digit> floating literal anymore; put 0 before dot 
 
...ommand "copy "X:\B2BPortal-0.0.1-SNAPSHOT.war" "C:\apache-to... 
 
...        ^
 
c:/chef/cache/cookbooks/file_sharing/recipes/default.rb:11: syntax error, unexpected tINTEGER 
 
...mmand "copy "X:\B2BPortal-0.0.1-SNAPSHOT.war" "C:\apache-tom... 
 
...        ^
 
c:/chef/cache/cookbooks/file_sharing/recipes/default.rb:11: syntax error, unexpected tSTRING_BEG, expecting keyword_end 
 
...:\B2BPortal-0.0.1-SNAPSHOT.war" "C:\apache-tomcat-6.0.32\apa... 
 
...        ^
 
c:/chef/cache/cookbooks/file_sharing/recipes/default.rb:11: syntax error, unexpected tCONSTANT, expecting keyword_end 
 
...2BPortal-0.0.1-SNAPSHOT.war" "C:\apache-tomcat-6.0.32\apache... 
 
...        ^
 
c:/chef/cache/cookbooks/file_sharing/recipes/default.rb:11: no .<digit> floating literal anymore; put 0 before dot 
 
...HOT.war" "C:\apache-tomcat-6.0.32\apache-tomcat-6.0.32\webap... 
 
...        ^
 
c:/chef/cache/cookbooks/file_sharing/recipes/default.rb:11: syntax error, unexpected tINTEGER 
 
...T.war" "C:\apache-tomcat-6.0.32\apache-tomcat-6.0.32\webapps... 
 
...        ^
 
c:/chef/cache/cookbooks/file_sharing/recipes/default.rb:11: no .<digit> floating literal anymore; put 0 before dot 
 
...omcat-6.0.32\apache-tomcat-6.0.32\webapps"; /Y;" 
 
...        ^
 
c:/chef/cache/cookbooks/file_sharing/recipes/default.rb:11: syntax error, unexpected tINTEGER 
 
...cat-6.0.32\apache-tomcat-6.0.32\webapps"; /Y;"

] 1

回答

1

在Ruby中,\(反斜槓)用於類\n\t字符串轉義序列。您可以使用\\或單引號',因爲那些不處理反斜槓轉義。

0

您必須將雙引號和命令字符串中的反斜槓轉義出來,或者將其用單引號括起來。既然你沒有做任何可變插值,我會建議後者。

試試這個:

execute "file_sharing" do 
    command 'copy "X:\B2BPortal-0.0.1-SNAPSHOT.war" "C:\apache-tomcat-6.0.32\apache-tomcat-6.0.32\webapps" /Y;' 
end 
相關問題