Module: Shell

Defined in:
lib/vagrant_commands/shell.rb

Class Method Summary collapse

Class Method Details

.execute_command(command, box_name) ⇒ Object



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

def self.execute_command(command,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 "ssh -o StrictHostKeyChecking=no #{userName}@#{hostName} -p #{portNum} -i #{keyPath} \"#{command}\""
    puts `ssh -o StrictHostKeyChecking=no #{userName}@#{hostName} -p #{portNum} -i #{keyPath} \"#{command}\"`
end

.get_ssh_details(regex, box_name) ⇒ Object



11
12
13
14
# File 'lib/vagrant_commands/shell.rb', line 11

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