Sha256: 85e070a0376410ebcc5401130a198002fb0ffb0e5754c9231be2abe2ccc0ef16

Contents?: true

Size: 1.14 KB

Versions: 9

Compression:

Stored size: 1.14 KB

Contents

require "net/scp"
require "net/ssh"

module Traquitana
   class SSH
      attr_reader :host, :user, :options

      def initialize(host,user,options=nil)
         @host    = host
         @user    = user
         @options = options || {}
			STDOUT.puts "Connecting to #{@host} using user #{@user}"
      end

      def execute(cmds,verbose=false)
         rst = []
         Net::SSH.start(@host,@user,@options) do |ssh|
            for cmd in cmds
               STDOUT.puts "Executing #{cmd} on remote host ..." if verbose
               rst << ssh.exec!(cmd)
            end
         end
         rst
      end

      def send_files(col,updater=nil)
			Net::SCP.start(@host,@user,@options) do |scp|
            for files in col
               from, to = *files
               next if from.nil? || to.nil?
               scp.upload!(from,to) do |ch,name,sent,total|
                  if !updater.nil?
                     updater.name  = to
                     updater.total = total
                     updater.update(sent)
                  end
               end
               updater.reset if !updater.nil?
            end
         end
      end
   end
end

Version data entries

9 entries across 9 versions & 1 rubygems

Version Path
traquitana-0.0.20 lib/ssh.rb
traquitana-0.0.19 lib/ssh.rb
traquitana-0.0.18 lib/ssh.rb
traquitana-0.0.17 lib/ssh.rb
traquitana-0.0.16 lib/ssh.rb
traquitana-0.0.15 lib/ssh.rb
traquitana-0.0.14 lib/ssh.rb
traquitana-0.0.13 lib/ssh.rb
traquitana-0.0.12 lib/ssh.rb