2017-05-15 52 views
0

我有這個Exec的聲明:如何在Exec資源類型中執行bash命令行?

exec { 'Normalize MP3 filename': 
      environment => ["t=0"], 
      command => 'for i in *mp3; do mv -v $i track_`seq -f "%03g" $t $t`.mp3 ; t=`expr $t + 1`; done', 
      cwd  => "$resource_path/res/raw", 
    } -> 

當我的清單運行時,它得到這個錯誤:

Error: Could not find command 'for' 
Error: /Stage[main]/Make_it::App_mp3files/Exec[Normalize MP3 filename]/returns: change from notrun to 0 failed: Could not find command 'for' 

回答

2

在* nix操作系統默認的高管提供者是posix,這does not support shell built-ins such as for。您應該將提供程序更改爲shell以使用shell內置函數。

exec { 'Normalize MP3 filename': 
     environment => ["t=0"], 
     command => 'for i in *mp3; do mv -v $i track_`seq -f "%03g" $t $t`.mp3 ; t=`expr $t + 1`; done', 
     cwd  => "$resource_path/res/raw", 
     provider => 'shell', 
} ->