summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorGraham Inggs <ginggs@debian.org>2016-03-23 16:35:40 +0200
committerGraham Inggs <ginggs@debian.org>2016-03-23 16:35:40 +0200
commitf594b352e7e0866ec04f1149a68008593cf54faf (patch)
treee775142659d9b9deafa44aa2acf2a089e72adf89
downloaddebian_cronic-f594b352e7e0866ec04f1149a68008593cf54faf.tar.gz
debian_cronic-f594b352e7e0866ec04f1149a68008593cf54faf.tar.bz2
debian_cronic-f594b352e7e0866ec04f1149a68008593cf54faf.zip
Imported Upstream version 2upstream/2
-rw-r--r--cronic48
1 files changed, 48 insertions, 0 deletions
diff --git a/cronic b/cronic
new file mode 100644
index 0000000..8536f29
--- /dev/null
+++ b/cronic
@@ -0,0 +1,48 @@
+#!/bin/bash
+
+# Cronic v2 - cron job report wrapper
+# Copyright 2007 Chuck Houpt. No rights reserved, whatsoever.
+# Public Domain CC0: http://creativecommons.org/publicdomain/zero/1.0/
+
+set -eu
+
+OUT=/tmp/cronic.out.$$
+ERR=/tmp/cronic.err.$$
+TRACE=/tmp/cronic.trace.$$
+
+set +e
+"$@" >$OUT 2>$TRACE
+RESULT=$?
+set -e
+
+PATTERN="^${PS4:0:1}\\+${PS4:1}"
+if grep -aq "$PATTERN" $TRACE
+then
+ ! grep -av "$PATTERN" $TRACE > $ERR
+else
+ ERR=$TRACE
+fi
+
+if [ $RESULT -ne 0 -o -s "$ERR" ]
+ then
+ echo "Cronic detected failure or error output for the command:"
+ echo "$@"
+ echo
+ echo "RESULT CODE: $RESULT"
+ echo
+ echo "ERROR OUTPUT:"
+ cat "$ERR"
+ echo
+ echo "STANDARD OUTPUT:"
+ cat "$OUT"
+ if [ $TRACE != $ERR ]
+ then
+ echo
+ echo "TRACE-ERROR OUTPUT:"
+ cat "$TRACE"
+ fi
+fi
+
+rm -f "$OUT"
+rm -f "$ERR"
+rm -f "$TRACE"

© 2014-2024 Faster IT GmbH | imprint | privacy policy