Not able to run command in ruby block

HI, this is what my code looks like , somehow the #{host} below is not
replaced correctly in the grep,

any clues why ?

ruby_block “acc-deploy-host” do
block do
host=hostname -s
node.set[:acc_deploy] = cat /local_app/account-rest.properties | *grep -i "#{host}"* | cut -d":" -f2
puts "value is #{node[‘acc_deploy’]}"
end
end

Thanks
Manoj

Your backticks are being evaluatied during the compilation phase of the
chef-client run.
You want this: GitHub - chef/mixlib-shellout: mixin library for subprocess management, output collection

-s

On Tue, Oct 29, 2013 at 6:26 PM, Manoj Thakkar manoj.thakkar@gmail.comwrote:

HI, this is what my code looks like , somehow the #{host} below is not
replaced correctly in the grep,

any clues why ?

ruby_block "acc-deploy-host" do
block do
host=hostname -s
node.set[:acc_deploy] = cat /local_app/account-rest.properties | *grep -i "#{host}"* | cut -d":" -f2
puts "value is #{node['acc_deploy']}"
end
end

Thanks
Manoj

He should probably use mixlib-shellout, but the backticks are inside of
the ruby_block's block so they are evaluated at converge time. Are you
actually sure that it isn't printing out? You should probably use
Chef::Log.info rather than puts.

Douglas William Thrift
douglaswth@gmail.com
http://douglasthrift.net/

On 10/29/2013 4:50 PM, Sean OMeara wrote:

Your backticks are being evaluatied during the compilation phase of the
chef-client run.
You want this: GitHub - chef/mixlib-shellout: mixin library for subprocess management, output collection

-s

On Tue, Oct 29, 2013 at 6:26 PM, Manoj Thakkar <manoj.thakkar@gmail.com
mailto:manoj.thakkar@gmail.com> wrote:

HI, this is what my code looks like , somehow the #{host} below is
not replaced correctly in the grep,

any clues why ? 
 

 ruby_block "acc-deploy-host" do
 block do
 host=`hostname -s`
 node.set[:acc_deploy] = `cat /local_app/account-rest.properties |
*grep -i "#{host}"* | cut -d":" -f2 `
 puts "value is #{node['acc_deploy']}"
end
 end

Thanks
Manoj