Module: Scp

Defined in:
lib/vagrant_commands/scp.rb

Class Method Summary collapse

Class Method Details

.execute_command(from_file, to_file, box_name) ⇒ Object



2
3
4
5
6
7
8
9
10
# File 'lib/vagrant_commands/scp.rb', line 2

def self.execute_command(from_file,to_file,box_name)
    portNum = get_ssh_details(/(?<=Port ).*/,box_name)
    keyPath = get_ssh_details(/(?<=IdentityFile ).*/,box_name)
    hostName = get_ssh_details(/(?<=HostName ).*/,box_name)
    userName = get_ssh_details(/(?<=User ).*/,box_name)

    puts "scp -o 'StrictHostKeyChecking no' -i #{keyPath} -P #{portNum} #{from_file} #{userName}@#{hostName}:#{to_file}"
    `scp -o 'StrictHostKeyChecking no' -i #{keyPath} -P #{portNum} #{from_file} #{userName}@#{hostName}:#{to_file}`
end

.get_ssh_details(regex, box_name) ⇒ Object



12
13
14
15
# File 'lib/vagrant_commands/scp.rb', line 12

def self.get_ssh_details(regex, box_name)
  response = `vagrant ssh-config #{box_name}`
  return response.match(regex)
end