Method: RHC::Commands::Ssh#run

Defined in:
lib/rhc/commands/ssh.rb

#run(_, command) ⇒ Object

Raises:

  • (ArgumentError)


27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
# File 'lib/rhc/commands/ssh.rb', line 27

def run(_, command)
  raise ArgumentError, "--gears requires a command" if options.gears && command.blank?
  raise ArgumentError, "--limit must be an integer greater than zero" if options.limit && options.limit < 1

  ssh = check_ssh_executable! options.ssh

  if options.gears
    run_on_gears(command.join(' '), find_app(:with_gear_groups => true))
    0
  else
    rest_app = find_app
    $stderr.puts "Connecting to #{rest_app.ssh_string.to_s} ..." unless command.present?

    debug "Using user specified SSH: #{options.ssh}" if options.ssh

    command_line = [ ssh.split, rest_app.ssh_string.to_s, command].flatten.compact
    debug "Invoking Kernel.exec with #{command_line.inspect}"
    Kernel.send(:exec, *command_line)
  end
end