Question

I am trying to build a SSH client for the web browser (similar to ajaxterm). I have built a python backend that uses Paramiko's SSHClient.invoke_shell(term='vt100') and a web server which communicates with a frontend (HTML + AJAX). The system works and displays output when I send commands through SSH channel, but the output includes VT100 escape sequences.

If I understand correctly, anything I get from the SSH channel should be interpreted as commands for 24x80 terminal window? Which means the escape sequences may change color, clear screen, remove lines, change the way lines behave... (I have found a good list here) Which means I can't just clear them out?

I checked out Ajaxterm's source, but couldn't figure out how Terminal class can be used (so I could use it for my purposes).

The question: what would be the easiest way to interpret the output stream and properly display the terminal screen in a browser? In other words, is there a library that parses the output and keeps the screen contents for me?

If I have misunderstood the inner workings of the terminals, please let me know. I haven't had much of experience with them in the past. :)

Was it helpful?

Solution

I've tried to do the same thing a few days ago. I didn't finished it, but I found a few python terminal emulator libs.

I choose pyte, which has a clean API and is easy to use. A list of other libs doing the same job is available at the end of pyte's README.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top