shell - Is it possible to use so = shellout("linux cmd") outside of Chef in ruby script? -


i'm curious, there possibility use shellout in ruby scripts outside of chef? how set this?

gem install mixlib-shellout

and in ruby script

require 'mixlib/shellout' cmd = mixlib::shellout.new('linux cmd') cmd.run_command # , optionally, raise exception if command fails shell_out!() cmd.error! 

eta: if want avoid creating instance yourself, dump wrapper fucntion in scripts use it:

def shellout(cmd, ok_exits = [0])   run = mixlib::shellout.new(cmd)   run.run_command   if run.error? || !ok_exits.include?(run.exitstatus)     puts "#{cmd} failed: #{run.stderr}"     exit 2   end   run.stdout end 

Comments

Popular posts from this blog

javascript - Slick Slider width recalculation -

jsf - PrimeFaces Datatable - What is f:facet actually doing? -

angular2 services - Angular 2 RC 4 Http post not firing -