I am VERY much a neophyte with shell scripting. I am working on the following,
"Create a script sends an email message to the user specified on the command line if any of the file
systems at more than 60% of capacity. The script should not process special file systems as /proc on
the ce.uml.edu. It should only process file systems which are either locally mounted or are mounted
via NFS."
This is my starting point:
#!/bin/bash
# script to send an email message to the user specified on the command line if
# any of the file systems at more than 60% of capacity.
df -H | grep -vE '^Filesystem' | 'none' | awk '{ print $1 " " $5 }' | while read fsout
do
echo "$fsout"
partition=$(echo "$fsout" | awk '{ print $2 }' )
usage=$(echo "$fsout" | awk '{ print $1 }' | cut -d'%' -f1)
if [ $usage -ge 90 ]
then
echo "CRITICAL WARNING!!: Filesystem \"$partition\" at "$usage"% of capacity" |
mail -s "CRITICAL WARNING!!: Filesystem \"$partition\" at "$usage"% of capacity" paul_peterson@student.uml.edu
elif [ $usage -ge 60 ] && [ $usage -lt 90 ]
then
echo "Warning!!: Filesystem \"$partition\" at "$usage"% of capacity" |
mail -s "Warning!!: Filesystem \"$partition\" at "$usage"% of capacity" paul_peterson@student.uml.edu
fi
done
I ma getting these errors:
./fsc.sh: line 4: $'\r': command not found
./fsc.sh: line 16: syntax error near unexpected token `elif'
'/fsc.sh: line 16: ` elif [ $usage -ge 60 ] && [ $usage -lt 90 ]
Any help is greatly appreciated.