lib/blower/host.rb
def sh (command, as: nil, quiet: false)
      as ||= @user
      output = ""
      synchronize do
        log.debug "sh #{command}", quiet: quiet
        result = nil
        ch = ssh(as).open_channel do |ch|
          ch.request_pty do |ch, success|
            "failed to acquire pty" unless success
            ch.exec(command) do |_, success|
              fail "failed to execute command" unless success
              ch.on_data do |_, data|
                log.trace "received #{data.bytesize} bytes stdout", quiet: quiet
                output << data
              end
              ch.on_extended_data do |_, _, data|
                log.trace "received #{data.bytesize} bytes stderr", quiet: quiet
                output << data.colorize(:red)
              end
              ch.on_request("exit-status") do |_, data|
                result = data.read_long
                log.trace "received exit-status #{result}", quiet: quiet
              end
            end
          end
        end
        ch.wait
        fail FailedCommand, output if result != 0
        output
      end
    end
def sh (command, as: nil, quiet: false)
      as ||= @user
      output = ""
      synchronize do
        log.debug "sh #{command}", quiet: quiet
        result = nil
        ch = ssh(as).open_channel do |ch|
          ch.request_pty do |ch, success|
            "failed to acquire pty" unless success
            ch.exec(command) do |_, success|
              fail "failed to execute command" unless success
              ch.on_data do |_, data|
                log.trace "received #{data.bytesize} bytes stdout", quiet: quiet
                output << data
              end
              ch.on_extended_data do |_, _, data|
                log.trace "received #{data.bytesize} bytes stderr", quiet: quiet
                output << data.colorize(:red)
              end
              ch.on_request("exit-status") do |_, data|
                result = data.read_long
                log.trace "received exit-status #{result}", quiet: quiet
              end
            end
          end
        end
        ch.wait
        fail FailedCommand, output if result != 0
        output
      end
    end
def sh ( command , as : nil , quiet : false ) as ||= @user output = "" synchronize do log . debug "sh #{command}" , quiet : quiet result = nil ch = ssh ( as ) . open_channel do | ch | ch . request_pty do | ch , success | "failed to acquire pty" unless success ch . exec ( command ) do | _ , success | fail "failed to execute command" unless success ch . on_data do | _ , data | log . trace "received #{data.bytesize} bytes stdout" , quiet : quiet output << data end ch . on_extended_data do | _ , _ , data | log . trace "received #{data.bytesize} bytes stderr" , quiet : quiet output << data . colorize ( :red ) end ch . on_request ( "exit-status" ) do | _ , data | result = data . read_long log . trace "received exit-status #{result}" , quiet : quiet end end end end ch . wait fail FailedCommand , output if result != 0 output end end
Execute a command on the host and return its output.
 @api private
Execute a command on the host and return its output .