Module: Kernel
- Defined in:
- lib/cloud/sh.rb
Instance Method Summary collapse
Instance Method Details
#cloud_sh_exec(*cmd, env: nil) ⇒ Object
28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 |
# File 'lib/cloud/sh.rb', line 28 def cloud_sh_exec(*cmd, env: nil) cmd = cmd.flatten.map(&:to_s).join(" ") args = env ? [env, cmd] : [cmd] = "Executing: #{cmd}" << " (#{env.inspect})" if env stdout, stderr, status = Open3.capture3(*args) unless status.success? puts "Command: #{cmd}" puts "ENV: #{env.inspect}" if env puts "Stdout:\n#{stdout}\n" puts "Stderr:\n#{stderr}\n" raise "Command failed!!!" end stdout end |