lib/remote/session.rb in remote-session-0.0.3 vs lib/remote/session.rb in remote-session-0.0.4
- old
+ new
@@ -1,6 +1,8 @@
+require 'remote/session/send'
require 'remote/session/send_file'
+require 'remote/session/send_string'
require 'remote/session/version'
require 'net/sftp'
require 'net/ssh'
require 'base64'
@@ -43,11 +45,11 @@
puts @session.exec!( command )
end
def sudo( commands )
raise "Session is closed" if @session.nil?
- commands = [ *commands ]
+ commands = [ *commands ] + [ 'exit' ]
@session.open_channel do |ch|
ch.request_pty do |ch, success|
raise "Could not obtain pty" if ! success
@@ -111,16 +113,13 @@
end
end
$stdout.write( data )
- if ch[ :commands ].size == 0
- ch.send_data "exit\n"
- return
- end
+ return if ch[ :commands ].size == 0
command = ch[ :commands ].shift
- if command.is_a?( Remote::Session::SendFile )
+ if command.is_a?( Remote::Session::Send )
send_file_chunk( ch, command )
else
ch.send_data "#{command}\n"
end
end