ansible - Ruby - display backtick output on console -


in ruby i'm using backticks execute (many) shell commands. how shell command output displayed on console?

a bit more detail. if run (ansible) command following, lots of scrolling output on console:

% ansible-playbook config.yml -e foo=bar -e baz=qux  play [base setup] **************************************************************  task [setup] ******************************************************************* ok: [10.99.66.210]  ... etc, etc 

however if execute same command ruby (using backticks) don't see output on console:

# cmd = ansible-playbook config.yml -e foo=bar -e baz=qux `#{cmd}` 

which unfortunate, i'd see output in order debug. redirect output ruby script (tailed) log file, want see output happens.

thanks david k-j's comment, ruby—open3.popen3

the solution me open3#popen2e, example:

# cmd = ansible-playbook config.yml -e foo=bar -e baz=qux puts cmd if execute   puts "executing..."   dir.chdir("..")     open3.popen2e(cmd) |i,oe,t|       oe.each { |line| puts line }     end   end end 

Comments

Popular posts from this blog

java - Run spring boot application error: Cannot instantiate interface org.springframework.context.ApplicationListener -

reactjs - React router and this.props.children - how to pass state to this.props.children -

Excel VBA "Microsoft Windows Common Controls 6.0 (SP6)" Location Changes -