- ## Net::SSH::Exceptions seem to happen every once in a while for
- ## no good reason.
- rescue Net::SSH::Exception, *RECOVERABLE_ERRORS
- if (retries += 1) <= 3
- @@shells_mutex.synchronize do
- @shell = nil
- @@shells[@key] = nil
- end
- retry
+ begin
+ unsafe_connect
+ if cmd
+ # MBox::debug "sending command: #{cmd.inspect}"
+ result = @shell_mutex.synchronize { x = @shell.send_command cmd; sleep 0.25; x }
+ raise SSHFileError, "Failure during remote command #{cmd.inspect}: #{(result.stderr || result.stdout || "")[0 .. 100]}" unless result.status == 0
+ end
+ ## Net::SSH::Exceptions seem to happen every once in a while for
+ ## no good reason.
+ rescue Net::SSH::Exception, *RECOVERABLE_ERRORS
+ if (retries += 1) <= 3
+ @@shells_mutex.synchronize do
+ @shell = nil
+ @@shells[@key] = nil