To debug common shell script problems run the script with 'sh -vx /path/to/script' as you'll see the commands and variables and such filled in. Anyway: unprotected (quoting) variable names, inconsistent variable names, unnecessary use of commands, inefficient alert message, here's an easy version:
Code:
#!/bin/sh --
df -H|awk '/\/dev\// {print $5, $1, $6}'|while read PERC DEV MOUNT; do
[ ${PERC//%/} -ge 70 ] && { /bin/true|mail -s "$(/bin/date +'%Y%m%d'): $(hostname): ${MOUNT} (${DEV}) ${PERC} full" user@address
done; exit 0
Also please edit your OP and remove the email addresses (wrt spam), TIA.
Code:
function help() { echo "Bash scripting guides:
http://www.tldp.org/HOWTO/Bash-Prog-Intro-HOWTO.html
http://www.tldp.org/LDP/Bash-Beginners-Guide/html/index.html
http://www.gnu.org/software/bash/manual/html_node/index.html
http://www.grymoire.com/Unix/Sh.html
http://www.tldp.org/LDP/abs/html/
http://wooledge.org/mywiki/BashFAQ?action=show&redirect=BashFaq
http://wooledge.org/mywiki/BashPitfalls"; }