I'm watching the error logs on my local setup. I'd like to have the errors print out in cowsay, you know, for fun. tail -f error_log | cowsay
doesn't work. Any ideas?
-
What's the error message? – VaTo May 29 '15 at 2:32
-
cowsay won't even get anything until there's like 1kb or 4kb in flight. – VaTo May 29 '15 at 2:37
-
no error message, just hangs – icicleking May 30 '15 at 2:39
cowsay
can print what is presented to it on stdin, but gathers the lines together until stdin is closed (maybe it does so as well when some buffer overflows, but 15Mb of text was not enough to do so).
If you want cowsay
to show every few lines you can pipe the output of the tail command into xargs
and have it invoke cowsay on e.g every 3rd line:
tail -f error_log | xargs -n3 cowsay
-
didn't quite work. it spit out some of the error log in cowsay, then
This shouldn't happen at /System/Library/Perl/5.18/Text/Wrap.pm line 84.
– icicleking May 29 '15 at 13:41 -
1@icicleking What system are you on? Maybe 'error_log' has overly long unwrappable lines. Have you tried with a small file
touch xyz ; tail -f xyz | xargs -n3 cowsay
and then in a different terminal window repeatedly doingecho abc >> xyz
? – Anthon May 29 '15 at 14:05 -
As I can do this on my Linux Mint 17 system as
sudo tail -f /var/log/syslog | xargs -n3 cowsay
(sudo in order to read thesyslog
owned log file) – Anthon May 29 '15 at 14:07 -
From the path in your error message it looks like you are on OS X, maybe cowsay and/or xargs are different there. I have no way to test that. – Anthon May 29 '15 at 14:08
-
I am on OSX. It appears to work the same. I tested on a smaller file and I don't get the Wrap error. However, it doesn't "live update" the way tail -f usually does. Reading about xargs, it looks like it echos over the standard input. I wonder if that's too static to do the continuous monitoring. – icicleking May 30 '15 at 2:40