Class: Specinfra::Backend::Ssh
- Defined in:
- lib/specinfra/backend/ssh.rb
Instance Method Summary collapse
Methods inherited from Base
Instance Method Details
#build_command(cmd) ⇒ Object
37 38 39 40 41 42 43 |
# File 'lib/specinfra/backend/ssh.rb', line 37 def build_command(cmd) cmd = super(cmd) if sudo? cmd = "#{sudo} -p '#{prompt}' #{cmd}" end cmd end |
#run_command(cmd, opt = {}) ⇒ Object
8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 |
# File 'lib/specinfra/backend/ssh.rb', line 8 def run_command(cmd, opt={}) cmd = build_command(cmd) cmd = add_pre_command(cmd) ret = with_env do ssh_exec!(cmd) 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 |
#send_file(from, to) ⇒ Object
26 27 28 29 30 31 32 33 34 35 |
# File 'lib/specinfra/backend/ssh.rb', line 26 def send_file(from, to) if Specinfra.configuration.scp.nil? Specinfra.configuration.scp = create_scp end tmp = File.join('/tmp', File.basename(to)) scp = Specinfra.configuration.scp scp.upload!(from, tmp) run_command(Specinfra.command.get(:move_file, tmp, to)) end |