I have an output file (namely a log from screen
) containing several control characters. Inside the screen, I have programs running that use control characters to refresh certain lines (examples would be top
or anything printing progress bars).
I would like to output a tail
of this file using PHP. If I simply read in that file and echo its contents (either using PHP functions or through calling tail
, the output is messy and much more than these last lines as it also includes things that have been overwritten. If I instead run tail
in the command line, it returns just what I want because the terminal evaluates the control characters.
So my question is: Is there a way to evaluate the control characters, getting the output that a terminal would show me, in a way that I could then use elsewhere (e.g., write to a file)?