?
Solved

Reading a flat unix file and emailing when the PCTUSED is greater than 50%

Posted on 2003-03-12
4
Medium Priority
?
324 Views
Last Modified: 2010-04-01
Hello,

I am trying to write a shell script that reads the unix flat file and email me those lines only when PCT_USED is greater than 50% and I got stuck. Can anyone please help me ASAP. Thanks in advance!

The flat file format looks like this:

HOSTNAME
FILESYSTEM ALLOCATED USED FREE PCTUSED MOUNTON

and the following is the script that I started out before I got stuck:

#!/bin/ksh                                                                      
                                                               
cat unix flat file |while read record              
do                                                                              
 num_col=`echo $record|wc -w`                                                  
 if [ $num_col -eq 1 ];                                                        
 then                                                                          
    HOSTNAME=${record}                                                          
echo $HOSTNAME                                                                  
 else                                                                          
    if  [ -n $record ];                                                        
    then                                                                        
      echo $record|read FILESYSTEM ALLOCATED USED FREE PCTUSED MOUNTON    
fi
fi
done      
The script works fine upto here and reads the values but then where I go from here, how do you give the condition: [if $PCTUSED -gt 50] then mailx $hostname, $filesystem,$allocated,$used,$free,$pctused,$mounton

Any help is appreciated!  
0
Comment
Question by:issa7860
  • 3
4 Comments
 
LVL 14

Expert Comment

by:kennethxu
ID: 8125050
this is jsp forum, you should have posted your question on unix forum. in the mean time, you might want to try:

mail xxx@yyy.com <<EOF
subject

$hostname, $filesystem,$allocated,$used,$free,$pctused,$mounton
.
EOF
0
 
LVL 14

Accepted Solution

by:
kennethxu earned 0 total points
ID: 8125058
0
 
LVL 14

Expert Comment

by:kennethxu
ID: 8171109
I'll get your points refunded.
0
 
LVL 5

Expert Comment

by:Netminder
ID: 8171762
Points refunded and grade changed.

Netminder
EE Admin
0

Featured Post

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

There's never been a better time to become a computer scientist. Employment growth in the field is expected to reach 22% overall by 2020, and if you want to get in on the action, it’s a good idea to think about at least minoring in computer science …
Before you approach an Ionic Mobile App development company for developing mobile apps using the ionic framework, you must know why you should choose the framework. Let's try to understand that through this article.
With just a little bit of  SQL and VBA, many doors open to cool things like synchronize a list box to display data relevant to other information on a form.  If you have never written code or looked at an SQL statement before, no problem! ...  give i…
Stellar Phoenix SQL Database Repair software easily fixes the suspect mode issue of SQL Server database. It is a simple process to bring the database from suspect mode to normal mode. Check out the video and fix the SQL database suspect mode problem.
Suggested Courses

621 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question