SSH .NET ShellStream characters cleanup

770 views Asked by At

I'm able to connect and push SSH .NET commands to the server but then I get some lines of illegible encoding I don't see when I connect trough PuTTy.

Like: [4i[?4i[0;1234c

Our IT says the console needs to be set to VT320 or VT400+. But I could not find any details on the documentation about this.

Is this feature supported by SSH.NET?

I already tried all encoding types for the StreamReader. I'm using this code from another post to read the console:

 public static string SendCommand(string cmd, ShellStream sh)
        {
            StreamReader reader = null;
            try
            {
                reader = new StreamReader(sh, Encoding.Default);
                StreamWriter writer = new StreamWriter(sh, Encoding.Default);
                writer.AutoFlush = true;
                writer.WriteLine(cmd);
                while (sh.Length == 0)
                {
                    Thread.Sleep(1500);
                }
            }
            catch (Exception ex)
            {
                Console.WriteLine("exception: " + ex.ToString());
            }

            return reader.ReadToEnd();
        }
1

There are 1 answers

0
Jeff Pappas On BEST ANSWER

Looks like it's for formatting and color like example shows on link eg. echo -e "\033[47m\033[1;37m White \033[0m"

https://github.com/yonchu/shell-color-pallet/blob/master/color16