Need Help on simple script as i dont know numch about UNIX scripting


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Need Help on simple script as i dont know numch about UNIX scripting
# 1  
Old 06-06-2015
Need Help on simple script as i dont know numch about UNIX scripting

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
Code:
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:

Code:
#!/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!!
# 2  
Old 06-06-2015
I am glad that you got your script to work.

If you could show us how you solved this problem it would help other forum readers learn from your experience.

And, who knows; other readers might be able to offer suggestions to further refine your script for faster results using fewer system resources.
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. OS X (Apple)

A simple reminder script for beginners to shell scripting.

(Apologies for any typos.) Well hands up those who have been in the following situation(s):- Your partner, (in my case the missus), sees that you are messing with your machine and says something like, "can you keep an eye on the dinner, I am going out shopping", and you look up glazed eyed... (3 Replies)
Discussion started by: wisecracker
3 Replies

2. UNIX for Dummies Questions & Answers

Call a UNIX script inside another and dont wait for it

Hi I have two scripts script1.sh and script2.sh(say this script is a long running). I want to call script2.sh inside and script1.sh,but when i call script2.sh i dont want to wait for script2 to complete and want this to run in back ground and go on next commands in script 1.sh and finally at the... (2 Replies)
Discussion started by: lijjumathew
2 Replies

3. Shell Programming and Scripting

Help/How-to - simple UNIX script / gzip (beginner)

Hey all, I would like to ask your help and sorry in advance for my ignorance since I am a complete beginner in this. I need to create a UNIX script that will: - scan a small number of folders and subfolders (see a similar file tree in the attachment) - - for each final folder (each of... (8 Replies)
Discussion started by: McNulty
8 Replies

4. Shell Programming and Scripting

need a script that does a simple task on multiple unix servers.

hi guys, i need a script that does a simple task on multiple aix servers. if possible with both telnet and ssh. the simple task i wanna do is connect to a server and run "ifconfig -a" and get the output. nextweek i need to do similar jobs on like 50 servers... :( can anybody help me with making... (2 Replies)
Discussion started by: curtis911
2 Replies

5. Shell Programming and Scripting

Cannot execute Unix command in a simple perl script

Am trying to lean perl scripting in Unix OS to automate my tasks. Please find the below perl script i have tried #!/usr/bin/perl -w print "Please Enter the VG name to be checked:"; $A = <>; print "Please Enter the free size to be checked in GB:"; $B = <>; $vgcheck = `vgdisplay... (7 Replies)
Discussion started by: jayachandran87
7 Replies

6. Shell Programming and Scripting

Simple unix variables in script

I'm creating a script that asks a user for a variable ex read filename; read numberinput; I also have a bunch of files named file.0 file.1 ... file.55 I'm trying to delete all files (if they exist) about file.$numberinput. Can someone help me out on how to include the variable as part... (6 Replies)
Discussion started by: jenix4545
6 Replies

7. Shell Programming and Scripting

A simple query on unix shell script

I want to write a script to go to particular path in file and run shell script from there. what will be shell script for the same. (2 Replies)
Discussion started by: shekhar_ssm
2 Replies

8. Shell Programming and Scripting

simple unix script help

when i run this script: # Author: xtos if then echo "Please enter ONLY one name to search, (example "$0" NAME)" exit fi INPUT="grep $1 $HOME/work/phone_book" if then echo "Listing not found, please try again." else (2 Replies)
Discussion started by: xtos
2 Replies

9. UNIX for Dummies Questions & Answers

Unix and Linuz - still dont get the difference

Hi I am a beginner, so go easy lol. first of all, what is the difference between unix and linux. after reading info on both of them i am still confused. secondly, i am going to buy a book to help me with unix. if i buy a beginners guide to linux will that be better then buying a beginners... (5 Replies)
Discussion started by: Vn3050
5 Replies

10. UNIX for Dummies Questions & Answers

Simple UNIX Shell Script help, PLEASE

I don't know anything about UNIX. I have been developing on NT platform and now a batch file I was running in my java code must work on UNIX instead. How do I change the below .bat file into a shell script that can be run on UNIX? Thanks in advance for your help. @ECHO OFF D:... (1 Reply)
Discussion started by: ci2a020
1 Replies
Login or Register to Ask a Question