I have a Chef recipe with a ruby_block containing this:
myoutput = `keytool -import -alias #{al} -keystore #{ks} -storepass #{pw} -file #{ca} -trustcacerts -noprompt`
puts ":" + myoutput + ":"
Chef::Log.error('Error installing CA Cert') unless myoutput.include? "Certificate was added to keystore"
(All of the variables are properly set.) Here's the relevant output:
Certificate was added to keystore
::
[2013-07-03T21:26:41-07:00] ERROR: Error installing CA Cert
Notice the ::. Why isn't myoutput being set correctly? When I run that command by hand, I get the expected output. The command in the backticks does what it's supposed to, so I know it's running, but for some reason the standard output from the command is not getting assigned to myoutput and I can't figure out why. Any ideas? Thanks -- Dave
Edit: the reason is because the output of this particular 'keytool' invocation is going to stderr, not stdout.