SEJBR
SEJBR

Reputation: 369

MPlayer screenlog output

my friend is creating mplayer server on Raspberry PI and is currently trying to check screenlog for current time. The problem starts with getting the last line. Doesn't matter if we use tail, awk, read or anything else, the console output is always breaking lines and refreshing (sortof). Using cat also doesn't output whole file, but line by line removing the previous one. MPlayer add's '\033[K' to all lines, and it appears there's no way of removing it by sed, or defining other IFS.

Here are some outputs:

[bot@aurora ~]$ tail -n 1 screenlog.0
A: 00:00:57 / 00:04:19 (21%) Cache: 45%[bot@aurora ~]$
[bot@aurora ~]$ tail -n 1 screenlog.0 | awk {'print $2'}
00:00:00


[bot@aurora ~]$ awk '/./{line=$0} END{print line}' screenlog.0
A: 00:00:57 / 00:04:19 (21%) Cache: 45%
[bot@aurora ~]$ awk '/./{line=$0} END{print line}' screenlog.0 | awk {'print $2'}
00:00:00

Here's the screenlog : http://sejbr.max-play.pl/screenlog.0

Upvotes: 0

Views: 286

Answers (2)

SEJBR
SEJBR

Reputation: 369

My friend came up with a solution. The easiest way is to use something outside bash, like PHP.

$data = file_get_contents('/tmp/mplayer');
$data = preg_replace('/\<ESC>\[K/' , "\n", $data);
echo $data;

Well that was pretty simple in a way :P.

Thank you all for responding.

Upvotes: 0

Mike
Mike

Reputation: 2464

pipe mplayer's output through 'strings', like so:

mplayer file | strings >screenlog.0

Upvotes: 1

Related Questions