Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations sizbut on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

mail command problem 1

Status
Not open for further replies.

Marcel1958

Technical User
Oct 11, 2001
38
NL
I need to monitor the disk space so i wrote this little script to send an email when the free space is to low. Problem is that when the first problem is found the script stops. When i do only the echo command it works ok.

user0="root"
user1="mg.bogaard@xxx.nl"
user2="r.van_der.vliet@xxx.nl"
user3="boogjes@xxx.com"

HOSTNAME=`hostname`

df -k | tr -d "%" |
while read filesystem blocks free gebruik A1 iused mounted
do

if [ "$gebruik" -gt "60" ]
then
echo $mounted $gebruik
mail -s "$filesystem on $HOSTNAME is $gebruik % vol" -c "$user1" $user0
fi fi
done
 
Thanks rzs0502. I have seen this FAQ but mij problem is that the script stops when i use the mailx command. If i run the script without this is works ok.
 
the script stops when i use the mailx command
Doesn't it instead wait for the body of the message as its standard input isn't redirected ?
Furthermore, the code snippet you posted contains syntax error on the following line:
fi fi

Hope This Help, PH.
Want to get great answers to your Tek-Tips questions? Have a look at FAQ219-2884 or FAQ222-2244
 
Try using this for your mailing

MESSAGE="Ek is $gebruik vol"
echo $MESSAGE | mailx -s "$SUBJECT" "$RECIPIENTS"

Works on my AIX machine but not on my Linux laptop.
Hope it helps


"If you always do what you've always done, you will always be where you've always been."
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top