Code

Typo
[nagiosplug.git] / tools / mail_error
index 4349c21d68a648ebd2d487aa216c11543671b481..aabb579ce744f55778a29b0c5d867ffb6098a18c 100755 (executable)
@@ -1,10 +1,14 @@
 #!/bin/bash
 # mail_error -o file -m email_address command
-# Runs command and redirects all output to file
-# If command rc != 0, sends file to email_address
+# Runs command from cron and redirects all output to file
+# If command rc != 0, sends output to email_address
 
 function die { echo $1 ; exit 1; }
 
+# Must be export so that sfsnapshot uses correct versions
+# of GNU toolchain
+export PATH=$HOME/bin:$HOME/local/bin:$PATH
+
 while getopts "o:m:" c; do
        case $c in
                o) output_file=$OPTARG;;
@@ -13,10 +17,9 @@ while getopts "o:m:" c; do
        esac
 done
 shift $(($OPTIND-1))
-echo "output_file=$output_file email=$email"
 
 [[ -z $1 ]] && die "Must specify command"
 
 if ! "$@" > $output_file 2>&1 ; then
-       mail -s "mail_error fail: $@" $email < $output_file
+       mail -s "mail_error fail: $1" $email < $output_file
 fi