# File lib/net/ssh/service/shell/sync.rb, line 54
          def send_command( cmd, stdin=nil )
            @log.debug "executing #{cmd.inspect}" if @log.debug?
            send_data "#{cmd}; echo -n #{CONFIRMATION} $?\n"
            send_data stdin if stdin

            out = ""
            err = ""

            @log.debug "waiting for #{cmd.inspect}" if @log.debug?
            loop do
              sleep 0.01
              out << @shell.stdout while @shell.open? && @shell.stdout?
              err << @shell.stderr while @shell.open? && @shell.stderr?

              break if !@shell.open? || out.index( CONFIRMATION + " " )
            end

            if @log.debug?
              @log.debug "#{cmd.inspect} finished"
              @log.debug " stdout --> #{out.inspect}"
              @log.debug " stderr --> #{err.inspect}"
            end

            if @shell.open?
              match = out.match( /#{CONFIRMATION} /o )
              out = match.pre_match
              status = match.post_match.strip.to_i
            else
              status = 0
            end

            CommandOutput.new( out, ( err.empty? ? nil : err ), status )
          end