Ask Your Question
2

How can I execute bash command line in Exec resource type?

asked 2017-05-15 00:33:17 -0500

Red Cricket gravatar image

updated 2017-05-15 11:41:10 -0500

smarlow gravatar image

Hi,

I have this Exec declaration:

    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",
    } ->

When my manifest runs it get this error:

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'
edit retag flag offensive close merge delete

1 Answer

Sort by ยป oldest newest most voted
2

answered 2017-05-15 03:14:19 -0500

domcleal gravatar image

The default exec provider on *nix OSes is posix, which does not support shell built-ins such as for. You should change the provider to shell to use shell built-ins.

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',
} ->
edit flag offensive delete link more

Your Answer

Please start posting anonymously - your entry will be published after you log in or create a new account.

Add Answer

Question Tools

1 follower

Stats

Asked: 2017-05-15 00:33:17 -0500

Seen: 46 times

Last updated: May 15