summaryrefslogtreecommitdiff
path: root/scripts
diff options
context:
space:
mode:
authorrandomdan <randomdan@localhost>2005-09-07 20:33:52 +0000
committerrandomdan <randomdan@localhost>2005-09-07 20:33:52 +0000
commitda81bbd1d1b8a152d672e64c86da3a8fec7de269 (patch)
tree0116413183e653a5df4ea8637c1f40ca8fabfc2d /scripts
parentUnmasked mythmusic - faad2 (diff)
downloadconfig-da81bbd1d1b8a152d672e64c86da3a8fec7de269.tar.bz2
config-da81bbd1d1b8a152d672e64c86da3a8fec7de269.tar.xz
config-da81bbd1d1b8a152d672e64c86da3a8fec7de269.zip
Mail logger
Diffstat (limited to 'scripts')
-rwxr-xr-xscripts/mail-logger.sh29
1 files changed, 29 insertions, 0 deletions
diff --git a/scripts/mail-logger.sh b/scripts/mail-logger.sh
new file mode 100755
index 0000000..5734a28
--- /dev/null
+++ b/scripts/mail-logger.sh
@@ -0,0 +1,29 @@
+# Script mailer
+
+if [ "$1" = "" -o "$2" = "" ] ; then
+ echo "Usage"
+ echo "$0 <mailto> <script> [<script_args> ...]"
+ exit 1
+fi
+
+MAILTO="$1";
+BASE="/tmp/$$"
+LOGO="${BASE}o";
+LOGE="${BASE}e";
+SCRIPT="${BASE}s";
+shift;
+
+# Execute the script
+echo "$@" > "${SCRIPT}";
+chmod +x "${SCRIPT}"
+"${SCRIPT}" > "${LOGO}" 2> "${LOGE}";
+
+if [ -s "${LOGE}" ] ; then
+ mailx -s "Errors from ${1}" "${MAILTO}" < "${LOGE}";
+fi
+if [ -s "${LOGO}" ] ; then
+ mailx -s "Output from ${1}" "${MAILTO}" < "${LOGO}";
+fi
+rm "${LOGO}" "${LOGE}" "${SCRIPT}"
+
+