Method: Specinfra::Backend::Ssh#run_command

Defined in:
lib/specinfra/backend/ssh.rb

#run_command(cmd, opt = {}) ⇒ Object



9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
# File 'lib/specinfra/backend/ssh.rb', line 9

def run_command(cmd, opt={})
  cmd = build_command(cmd)
  cmd = add_pre_command(cmd)

  if get_config(:ssh_without_env)
    ret = ssh_exec!(cmd)
  else
    ret = with_env do
      ssh_exec!(cmd)
    end
  end

  ret[:stdout].gsub!(/\r\n/, "\n")
  ret[:stdout].gsub!(/\A\n/, "") if sudo?

  if @example
    @example.[:command] = cmd
    @example.[:stdout]  = ret[:stdout]
  end

  CommandResult.new ret
end