Chef ruby_block ShellOut mysql result stdout forever empty

506 Views Asked by At

have an next case:

test3 = Mixlib::ShellOut.new("echo '1'")
test4 = Mixlib::ShellOut.new("mysql -u root --silent --skip-column-names --password='rootpass' -e 'some sql;'")
test3.run_command
test4.run_command

puts test3.stdout # => 1
puts test4.stdout # => empty string, nothing

expecting test4 to return result as test3

I guess maybe mysql returning result not to stdout, where then and how can I get the result

P.S I know about ruby gem mysql2 which I could use for doing this stuff, but to be honest no time to implement stuff like this just to getting only a simple SQL result, also I have tried run command without --silent and --skip-column-names flags, and this doesn't help too.

1

There are 1 best solutions below

0
On

So the problem was, my command was returning code exit 1, it seems it was failing, so after fixing the command it works, the problem was in using single comma instead of double comma