Hello All,
My name is vasu and I am very new to Unix scripting, i know basic commands, but now i need to write the following script, i have tried but no luck
My requirment is i am getting one our from another command as following
Used:1.8TB Advisory Quota:1.8TB aaa1
Used:4.5TB Advisory Quota:4.5TB aaa2
Used:4TB Advisory Quota:4TB aaa3
Used:800.17GB Advisory Quota:800GB aaa4
Used:1.5TB Advisory Quota:1.5TB aaa5
Used:2.03GB Advisory Quota:2GB aaa6
Used:2.03GB Advisory Quota:2GB aaa7
Used:2.04GB Advisory Quota:2GB aaa8
Used:2.01GB Advisory Quota:2GB aaa9
Used:2GB Advisory Quota:2GB aaa10
Used:2.06GB Advisory Quota:2GB aaa11
Used:2.04GB Advisory Quota:2GB aaa12
Used:2.06GB Advisory Quota:2GB aaa13
Used:2.06GB Advisory Quota:2GB aaa14
Used:2.06GB Advisory Quota:2GB aaa15
Used:2.02GB Advisory Quota:2GB aaa16
Used:2.06GB Advisory Quota:2GB aaa17
In above aaa.. is user id, now i am trying to read this output from another command and need to send mail to every user with details like "Hi $user,\n The user $user Exceeded Advisory Quota Usage on `hostname`,Please cleanup \n \n USED\t\tQUOTA LIMIT\t\tUSER \n Used:1.8TB Advisory Quota:1.8TB aaa1"
I have tried like following:
#!/bin/bash
awk '{print $7$8$9"\t"$10" "$11$12$13$14"\t"$15}'> quota-1
n=wc -l quota-1
while [read data -le $n]
do
{
used=`echo $data|awk '{print $1}'`
quota=`echo $data|awk '{print $2" "$3}'`
user=`echo $data|awk '{print $4}'`
echo -e $used'\t'$quota'\t'$user'\n'
#mailid=`ldapsearch -h idnsup7l -p 17113 -x -b "dc=idn,dc=aexp,dc=com" "uid=$user" mail| awk '/mail:/{print $2}'`
echo -e "Hi $user,\n The user $user Exceeded Advisory Quota Usage on `hostname`,Please cleanup \n \n USED\t\tQUOTA LIMIT\t\tUSER \n `cat $file`" |#mailx -s "Silver Edge Node - Exceeded Advisory Quota Usage on `hostname`" -r SuperUser venkatakishore.b.bellam@aexp.com
}
done
Thanks in advance
Your Vasu
---------- Post updated at 12:27 PM ---------- Previous update was at 12:26 PM ----------
I am sorry for this, just now i got the output, please ignore this thread, Thanks for checking though!!