lib/incremental_backup/task.rb
def execute_ssh(commands)
      commands = [commands] unless commands.is_a? Array
      result = ""
      Net::SSH.start settings.remote_server, settings.remote_user do |ssh|
        commands.each do |command|
          was_error = false
          logger.info "ssh: #{command}"
          ssh.exec! command do |channel, stream, data|
            case stream
            when :stdout
              logger.info data
              result += "#{data}\n" unless data.empty?
            when :stderr
              logger.error data
              was_error = true
            end
          end
          throw "Exception during ssh, look in log file" if was_error
        end
      end
      result
    end
def execute_ssh(commands)
      commands = [commands] unless commands.is_a? Array
      result = ""
      Net::SSH.start settings.remote_server, settings.remote_user do |ssh|
        commands.each do |command|
          was_error = false
          logger.info "ssh: #{command}"
          ssh.exec! command do |channel, stream, data|
            case stream
            when :stdout
              logger.info data
              result += "#{data}\n" unless data.empty?
            when :stderr
              logger.error data
              was_error = true
            end
          end
          throw "Exception during ssh, look in log file" if was_error
        end
      end
      result
    end
def execute_ssh ( commands ) commands = [ commands ] unless commands . is_a? Array result = "" Net :: SSH . start settings . remote_server , settings . remote_user do | ssh | commands . each do | command | was_error = false logger . info "ssh: #{command}" ssh . exec! command do | channel , stream , data | case stream when :stdout logger . info data result += "#{data}\n" unless data . empty? when :stderr logger . error data was_error = true end end throw "Exception during ssh, look in log file" if was_error end end result end
Runs one ore more commands remotely via ssh
Runs one ore more commands remotely via ssh