Quantcast
Channel: Admins Goodies » stderr
Viewing all articles
Browse latest Browse all 10

Unix: Delayed stderr display

$
0
0

Question

Is there a way to display errors summary (from stderr) after an application has finished?

E.g. rsync with “–progress” displays LOTS of data, including errors. But when it finishes – it just says “there were errors”. I want to display everything that was written to stderr in that case, so i don’t have to scroll and search what precisely went wrong :)

P.S. I know how simple it is to write such utility in C, but i guess there can be more handy things i’m not aware of :)

Answer

A wrapper script to handle this:

#!/bin/shTMPFILE=$(mktemp)"$@" 2>$TMPFILEif [ "$?" != "0" ]; then
  cat $TMPFILE
fi

If you save this to /usr/local/bin/delaystderr and chmod, you should be able to run as delaystderr rsync –progress. If the process exits without signalling error (returning non-zero), stderr won't be printed; you can delete the lines starting with if and fi` to disable that behaviour if you like.

I’m not sure how you’d get any easier than that.

(Note: I haven’t actually tested this script, so buyer beware and all that)


Viewing all articles
Browse latest Browse all 10

Trending Articles