class Hem::Lib::Vm::ReverseCommand
Place the ssh configuration within a command, using sprintf
Public Instance Methods
to_s()
click to toggle source
# File lib/hem/lib/vm/ReverseCommand.rb, line 12 def to_s ssh_config = ssh_config() ssh_command = ssh_command(ssh_config) pwd_set_command = pwd_set_command() vm_command = vm_command() [ @pipe, full_command(pwd_set_command, vm_command, ssh_command) ].compact.join(' | ') end
Private Instance Methods
full_command(pwd_set_command, vm_command, ssh_command)
click to toggle source
# File lib/hem/lib/vm/ReverseCommand.rb, line 56 def full_command(pwd_set_command, vm_command, ssh_command) [ pwd_set_command, vm_command.empty? ? nil : (vm_command % ssh_command).shellescape ].compact.join(' -c ') + @opts[:append].shellescape end
pwd_set_command()
click to toggle source
# File lib/hem/lib/vm/ReverseCommand.rb, line 45 def pwd_set_command "cd #{@opts[:pwd].shellescape}; exec /bin/bash" end
ssh_command(config)
click to toggle source
# File lib/hem/lib/vm/ReverseCommand.rb, line 36 def ssh_command(config) psuedo_tty = @opts[:psuedo_tty] ? '-t' : '' [ 'ssh', "-F #{config.path.shellescape}", psuedo_tty ].reject(&:empty?).join(' ') end
ssh_config()
click to toggle source
# File lib/hem/lib/vm/ReverseCommand.rb, line 26 def ssh_config require 'tempfile' config = ::Tempfile.new 'hem_ssh_config' config.write @@vm_inspector.ssh_config config.close config end
vm_command()
click to toggle source
# File lib/hem/lib/vm/ReverseCommand.rb, line 49 def vm_command [ @pipe_in_vm.nil? ? nil : @pipe_in_vm.gsub(/(\\+)/, '\\\\\1'), @command ].compact.join(' | ') end