How does one display/visualize a trace of a session with ANSI Escape codes embedded in it?

I have a tshark trace of a telnet session to a HP switch. From that, I Follow TCP Stream and get a pseudo-text representation of the telnet session (with embedded escape chars).

less hptelnet.escape

can be used to display it, but that breaks down quickly as the file gets just slightly bigger.

I've concocted a quick script that makes it sort of readable but it is far from finished. The ANSI escape sequences are just not simple.

Does anybody have any better ideas as to how one can view the "contents" of such a telnet trace?


One idea is to write a script that replays the data, in a controlled way, to a terminal of the appropriate type (e.g. an "ANSI" terminal emulator)

By controlled I mean send the next escape sequence (or contiguous set of escape sequences) plus following non-escape data and then wait for keyboard input. That way the viewer presses Enter (say) to have the next display element added to the display.

I don't know of any existing program or script that does this.

What I usually do is run the data through a script that inserts a newline before each Escape character (and sometimes replace the Escape character with a symbolic name such as "Esc". I then view the data using an editor (vim). This isn't exactly a visualization of the data but, in reality, there are not that many different patterns of escape characters used in logged data that I have looked at - so it's not too hard to see what is happening.

  • Thanks, yeah I went that way too, and created "Beginnings of ANSI Escape displayer": pastebin.com/VXUtcj8W, but Server Fault wouldn't let me post more than one link :-( – Peter V. Mørch Oct 22 '10 at 5:49

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.