output of unix command in chef recipe
Okay, so finally at a keyboard and can write this out in full.
The literal translation of what you have there would be:
execute 'run dynamically generated install file' do command 'make install' cwd lazy { shell_out!('ls -Adrt /tmp/unixODBC.* | tail -n 1').stdout.strip }end
However that is going to be much slower than needed and more failure prone so I would recommend writing it in Ruby instead:
execute 'run dynamically generated install file' do command 'make install' cwd lazy { Dir['/tmp/unixODBC.*'].first }end
This avoids having to spawn a bunch of processes and instead just does the same (I think) logic directly.
You should be able to do it just like this:
execute 'run dynamically generated install file' do command 'make install' cwd `ls -Adrt /tmp/unixODBC.* | tail -n 1`end
That seems like it's out of the scope of an execute
block.
Maybe just use a ruby_block
?
ruby_block 'run dynamically generated install file' do require 'mixlib/shellout' block do cmd = Mixlib::ShellOut.new('make install') cmd.run_command cwd = cmd.stdout # Do more stuff with cwd... endend