module Extensions::Net::SSH::Connection::Session
Public Instance Methods
exec(command, status: nil, &block)
click to toggle source
Calls superclass method
# File lib/extensions/net/ssh/connection/session.rb, line 9 def exec(command, status: nil, &block) return super(command, status: status, &block) unless localhost? result = exec_local_command(command) # Return status if given if status status[:exit_code] = result[:code] status[:exit_signal] = result[:signal] end # Process results if result[:error].nil? if block block.call(nil, :stdout, result[:output]) else $stdout.print(result[:output]) end else if block block.call(nil, :stderr, result[:error]) else $stderr.print(result[:error]) end end end
send_data(data)
click to toggle source
Calls superclass method
# File lib/extensions/net/ssh/connection/session.rb, line 36 def send_data(data) return super(data) unless localhost? binding.pry raise 'what do do here?' # stdin << data # maybe?? end
Private Instance Methods
exec_local_command(command)
click to toggle source
# File lib/extensions/net/ssh/connection/session.rb, line 50 def exec_local_command(command) result = {} begin result[:output] = `#{command}` rescue StandardError => e result[:error] = e.message ensure result[:code] = $?.exitstatus result[:signal] = $?.termsig result end end
localhost?()
click to toggle source
# File lib/extensions/net/ssh/connection/session.rb, line 46 def localhost? host == 'localhost' && options[:user].nil? end