Last active
February 26, 2017 15:52
-
-
Save tomgidden/0c8b5a21960a215b24657cc899dd165e to your computer and use it in GitHub Desktop.
Command line to partially cure get_iplayer's verbal diarrhoea. ie. don't show output unless/until ERROR or WARNING appears; then display it ALL.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
get_iplayer --pvr 2>&1 | perl -ne 'if(/ERROR|WARNING/){$q=1;print $b;undef $b;}if($q){print $_;}else{$b.=$_;}' |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
get_iplayer is excellent, but it does tend to be either too verbose, or absolutely silent, as the
--verbose
,--quiet
and--silent
options are a bit too hefty. Plus, if--pvr
is specified, the behaviour changes again.So, when run on a cron, you either get a massive email containing useless drivel, or nothing at all. Rather than just grep for errors (which would lose context), this perl one-liner will buffer all output. If no errors occur, then the script is silent, so cron won't send an email. If, however, it comes across
ERROR
orWARNING
, it'll output everything up to the error, and continue outputting everything afterwards.I really do wish someone would just improve the granularity of get_iplayer's logging instead.