SSH.NET Shell display output at the last line

Feb 6, 2014 at 3:55 PM
say you issue the following command:

apt-get install MySql

this command generates an output where some of the text is displayed line by line and some should be displayed at the last line. Here is an example :

Reading package lists... 0%

Reading package lists... 100%

Reading package lists... Done


Building dependency tree... 0%

Building dependency tree... 0%

Building dependency tree... 50%

Building dependency tree... 50%

Building dependency tree


Reading state information... 0%

Reading state information... 1%

Reading state information... Done


These lines should be overwritten. How to handle this output stream to emulate what remote shell does.
I am using ShellStream functionality

Thank you.
Feb 6, 2014 at 4:00 PM
Implement a Terminal, which is not simple.
You have to parse and handle control chars.

http://www.codeproject.com/Articles/13422/Terminal-Control-Project-C-VT100-SSH-Telnet
http://www.codeproject.com/Articles/20781/Terminal-Control-Library-C-VT100-ANSI-XTERM-SSH-Te
http://en.wikipedia.org/wiki/Control_character
http://stackoverflow.com/questions/3134059/vt100-emulation-library-in-c-sharp-with-sharpssh

So far I haven't found a good terminal emulator in C#.
And hacking it on your own is huge task and must be worth the effort.
Feb 6, 2014 at 4:33 PM
thank you for a quick reply.
Indeed, a challenging task. On top of it, I want to emulate it in Silverlight.

Thanks again for the references.
Feb 6, 2014 at 4:46 PM
with that being said.
I am new to SSH.NET and still learning.

What would be the best point to start?

the following code

     static void ycmd(string cmd, StreamReader reader, StreamWriter writer, ShellStream stream) {
        writer.WriteLine(cmd);

        while (stream.Length == 0) {
            System.Threading.Thread.Sleep(500);
        }

        string line = reader.ReadLine();
        while (line != null) {
            Console.WriteLine(line);
            line = reader.ReadLine();
        }
    }

where streams are defined as follows

  using (var stream = ssh.CreateShellStream("dumb", 80, 24, 800, 600, 1024)) {
                var reader = new StreamReader(stream);
                var writer = new StreamWriter(stream);


already, provides all the formatting of the input/output sequences .
So, the question is what needs to changed to format this output?


Thank you.