This project is read-only.

Xterm escape sequences appearing in SshStream

Oct 24, 2013 at 1:02 PM
Hi

I have some code which connects to a freesshd server installed on Windows. I'm then trying to read the SshStream to a variable and it's coming out a big mess. Example value of _buffer and example code below
_client = new SshClient(new ConnectionInfo(_address, _port, _user, nAuth, pAuth, kAuth));
            _stream = _client.CreateShellStream("xterm", 100, 100,100,100,10000);

            _bufferTask = Task.Factory.StartNew(
                () =>
                    {
                        try
                        {
                            while (true)
                            {
                                byte[] buf = new byte[2048];
                                int readCount = _stream.Read(buf, 0, 2048);
                                buf = buf.Slice(0, readCount);
                                string sBuf = _client.ConnectionInfo.Encoding.GetString(buf);
                            }
                        }
                        catch (Exception e)
                        {
                            Log.Exc("Exception in SSH output read", e);
                        }
                    });
            WriteLine("ping localhost -n 150");
C:\ProgramData\Microsoft\Windows\Start Menu\Programs\freeSSHd>ping localhost -n150PPinPingiPingingPinging bPinging benPinging benboPinging benbookPinging benbook-wPinging benbook-winPinging benbook-win [Pinging benbook-win [::Pinging benbook-win [::1]Pinging benbook-win [::1] wiPinging benbook-win [::1] withPinging benbook-win [::1] with 3Pinging benbook-win [::1] with 32Pinging benbook-win [::1] with 32 byPinging benbook-win [::1] with 32 bytePinging benbook-win [::1] with 32 bytesPinging benbook-win [::1] with 32 bytes ofPinging benbook-win [::1] with 32 bytes of dPinging benbook-win [::1] with 32 bytes of datPinging benbook-win [::1] with 32 bytes of data:RRepReplReplyReply frReply froReply fromReply from ::Reply from ::1:Reply from ::1: tReply from ::1: timReply from ::1: time<Reply from ::1: time<1mReply from ::1: time<1msRRepReplyReply fReply froReply fromReply from ::Reply from ::1:Reply from ::1: tiReply from ::1: timeReply from ::1: time<1Reply from ::1: time<1msRRepReplyReply fReply froReply fromReply from ::Reply from ::1:Reply from ::1: tiReply from ::1: timeReply from ::1: time<1Reply from ::1: time<1msRRepReplyReply fReply frReply froReply fromReply from :Reply from ::Reply from ::1Reply from ::1:Reply from ::1: tReply from ::1: timReply from ::1: time<Reply from ::1: time<1mReply from ::1: time<1msRRepReplyReply fReply froReply fromReply from ::Reply from ::1:Reply from ::1: tiReply from ::1: timeReply from ::1: time<1Reply from ::1: time<1ms