Module: Upload

Defined in:
rlib/upload.rb

Overview

SCP helper

Class Method Summary (collapse)

Class Method Details

+ (Object) upload_file(source_file, dest_file, dest_host, keyfile)

Do an scp source_file dest_host:dest_file using the keyfile for authentication.

Parameters:

  • source_file (String)

    The file to copy

  • dest_file (String)

    The remote file name we are copying to

  • dest_host (String)

    The host name we are copying to

  • keyfile (String)

    The filename of the id_rsa file we are using to authenticate with.



12
13
14
15
16
17
18
19
20
# File 'rlib/upload.rb', line 12

def self.upload_file(source_file, dest_file, dest_host, keyfile)
	begin
		Net::SCP.start(dest_host, 'root', :keys => [ keyfile ]) do |scp|
	    scp.upload!( source_file, dest_file )
		end
  rescue Exception => error
    $stderr.puts "upload_file('#{source_file}', '#{dest_file}', '#{dest_host}', '#{keyfile}') Scp failed with error: #{error}"
  end
end