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 Westi on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

How to interact awk <-> mail command ?

Status
Not open for further replies.

haneo

Programmer
Jan 2, 2002
274
CA
Hello every body ;)

I have a mail server to admin, with postfix and quota, all mails are stored in /home/user/.mailbox.

I want to write a shell script that start evry 00H01 so it will verify the quota of users, and if user have mailbox size great than the soft quota limit, this script will send warning email to that user.

But how to interact between awk and system command (mail)?

I do in shell #repquota -a | Myscript.sh

So here is the (ugly ) small script i write:

############################################################
#!/bin/gawk -f
{

if ($2 == "--"){
print "for user "$1" : all is well ;)"
echo -e "\a"
}else if ($2 == "+-" ){
print " for user "$1" : WRNING here !!!!"
}
}
############################################################


I have redhat 8.0 with compiled kernel 2.4.20 with quota enabled here is the output:
############################################################
[root@haneo /]# repquota -a
*** Report for user quotas on device /dev/hda7
Block grace time: 7days; Inode grace time: 7days
Block limits File limits
User used soft hard grace used soft hard grace
------------------------------------------------------------
root -- 1 0 0 2 0 0
haneo +- 109 100 200 7days 10 0 0

############################################################


Thanks for all !
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top