Server Fault is a question and answer site for system and network administrators. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

Is there a way to get rid of escape codes in terminal output?

Say even if the script are sending that codes they are ignored by terminal and text displayed as is, without colors, bolds etc.

I need to display terminal output on a HTML page.

For now i'm using javascript to remove escape codes, but it becomes clunky cause i receive output by chars, and have to wait until all content received then update it, leading in weird effects.

share|improve this question

closed as off topic by Michael Hampton, Magellan, Brent Pabst, mdpc, Ward Nov 5 '12 at 18:33

Questions on Server Fault are expected to relate to server, networking, or related infrastructure administration within the scope defined by the community. Consider editing the question or leaving comments for improvement if you believe the question can be reworded to fit within the scope. Read more about reopening questions here.If this question can be reworded to fit the rules in the help center, please edit the question.

A program can output anything on STDOUT, including escape codes, regardless of the value of TERM. However, setting TERM to 'dumb' will help with most programs which check the terminal capabilities for color support.

Also, some programs check that STDOUT is pointing at an interactive terminal and not a pipe or file before formatting their output. These programs can be redirected to a file, or piped through something else, such as cat or less -r.

If you narrow the problem down to a subset of escapes, those which change colors and not cursor position, you should be able to check for ESC, set a flag to stop echoing characters onto the page and clear the flag after an 'm'.

share|improve this answer

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