Among other problems with this script I am trying to make (this is the first unix/linux script I have ever made), I am trying to use df to get the % of disk space used and email it to the root. Our instructions were to exclude the /proc floppy and cdrom from df as well.
What I have so far:
fsExclude=(/proc /dev/floppy /dev/cdrom) #Exclusions from df file system fsUsed=15 #percent to watch for WarnEmail=root #email for warning message if (df -x $fsExclude | awk '$5' | sed '2p' > fsUsed) then df -h > dfFile.tmp mail -s "WARNING: Almost out of disk space %" '$WarnEmail' < dfFile.tmp rm dfFile.tmp fi
Now I know there is a few things wrong with this. When I run it just to see what kind of output I get, I get (the first line was a message above the if statement I didn't include above ):
Emailing admin, disk almost full... 3 $WarnEmail... User unknown 60 awk: cmd. line:1: print $4 awk: cmd. line:1: ^ parse error /root/dead.letter... Saved message in /root/dead.letter …
There is more but I will save that for later. I have mailed the root outside of the scrip in a similar fashion and had no issues but while in the script it doesn't want to work. With the awk of the df output, I just want to grab the value from that % used column to see if it is greater or less than the fsUsed value. If it is, go in and email the root the entire df output. I have seen while doing some googling that someone suggested using something that had a -perc or -avail but neither worked here. It would tell me that it those were unknown so I tried to go back to awk.
Any help on fixing this would be greatly appreciated.