Counting Files and send an email Notification if it exceeds a limit


 
Thread Tools Search this Thread
Top Forums UNIX for Dummies Questions & Answers Counting Files and send an email Notification if it exceeds a limit
# 1  
Old 07-07-2006
Counting Files and send an email Notification if it exceeds a limit

Hi,
I am trying to write a script to Count Files in a directory located on a remote server and send an email Notification if it exceeds a limit. The code given below doesnot check the condition and sends the mail everytime irrespective of the condition. I have put this script in the cron. Can anybody please point out the mistake I am making.

#!/bin/ksh
limit=50
file_length= rsh invuk "ssh poller "ls -ltr /var/spool/get | wc -l""
if [ $file_length -ge $limit ]; then
echo "Test mail." |mailx xyz@yahoo.com
fi

Thanks.

Last edited by amitsayshii; 07-07-2006 at 09:11 AM..
# 2  
Old 07-07-2006
Have you tested the script? Does it run ok if you run it manually? Have you setup the rsh and ssh password less authentication for the appropriate users?
# 3  
Old 07-07-2006
Yes it runs fine also the no of files returned is correct. Its just that the condition is not getting checked. Thanks
# 4  
Old 07-07-2006
Quote:
file_length= rsh invuk "ssh poller "ls -ltr /var/spool/get | wc -l""

i doubt here,

where is the value that is returned is assigned to file_length,

something like,

Code:
file_length=`ssh abc_server /usr/bin/ls -l /tmp | /usr/bin/wc -l`

# 5  
Old 07-07-2006
If I do echo $file_length I get the value.Correct me if I am not getting it...thanks
# 6  
Old 07-07-2006
Try running the script with a 'set -x' in the line after the '#!'. The debug output should show you the value of the file_length variable and also the if condition as it is evaluated.
And please remove your mail id from the first post.
# 7  
Old 07-07-2006
The issue seems to be with the value not getting populated in the file_length variable. The command gets run on the shell without the return value getting populated in the variable. How do I fix that. Thanks.
 
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Solaris

.profile[21]: ulimit: exceeds allowable limit

Hello All, I am having an issue with ellipse environment, Subscribing ellipse version /opt/mincom/ellipse/bs037__ora_cics_svr .profile: ulimit: exceeds allowable limit , prj -l ellsupp #ulimit -a time(seconds) unlimited file(blocks) unlimited data(kbytes) unlimited stack(kbytes) 8192... (22 Replies)
Discussion started by: Revathi2089
22 Replies

2. Shell Programming and Scripting

How to remove a file in shell script if its size exceeds limit?

How can i remove a file using shell script when its size exceeds 10MB. Given that file is located in different location to the shell script where it is running? (4 Replies)
Discussion started by: vel4ever
4 Replies

3. HP-UX

Script to send alert when process exceeds 90% cpu

I have an issue with one of the processes which is showing %cpu over 120% when i issue the top command. I am looking for a script that send me an email alert when it crosses the 90% thresholds. Appreciate your help (1 Reply)
Discussion started by: chkaiban
1 Replies

4. Shell Programming and Scripting

How to read specific line of text from a Script and send email notification

Hi ! I am a newbie and never officially wrote a shell script before. The requirement for this script is : 1) Read a file called 'bpm.log' and identify if it has a specific text such as 'this is the text'. Its a static value and that is the only text we need to read. 2) If that... (2 Replies)
Discussion started by: atechcorp
2 Replies

5. Shell Programming and Scripting

Script to send email after comparing the folder permissions to a certain permission & send email

Hello , I am trying to write a unix shell script to compare folder permission to say drwxr-x-wx and then send an email to my id in case the folders don't have the drwxr-x-wx permissions set for them . I have been trying to come up with a script for few days now , pls help me:( (2 Replies)
Discussion started by: nairshar
2 Replies

6. Shell Programming and Scripting

Check space of directories and send email if it has reached threshold limit

Hi, I need help in writing unix script for checking space of some directories on the system and also send an email when it reaches the threshold limit. I have written the followng code; #!/bin/ksh ADMIN="me@somewhere.com" # set alert level 80% is default THRESHOLD=80 df | grep -E... (5 Replies)
Discussion started by: jmathew99
5 Replies

7. Shell Programming and Scripting

Log Size Exceeds Limit

Everytime I try to start Discreet Flame on my Octane2 machine it keeps giving me an error message "initial log size exceeds limit--aborting" Can anyone please help me how to fix this problem. Thanks. Octane2 IRIX64 Release 6.5 Flame 2007 (6 Replies)
Discussion started by: dewaraja
6 Replies

8. UNIX for Advanced & Expert Users

Log Size Exceeds Limit

Everytime I try to start Discreet Flame on my Octane2 machine it keeps giving me an error message "initial log size exceeds limit--aborting" Can anyone please help me how to fix this problem. Thanks. Octane2 IRIX64 Release 6.5 Flame 2007 (0 Replies)
Discussion started by: dewaraja
0 Replies

9. UNIX for Dummies Questions & Answers

Log Size Exceeds Limit

Everytime I try to start Discreet Flame on my Octane2 machine it keeps giving me an error message "initial log size exceeds limit--aborting" Can anyone please help me how to fix this problem. Thanks. Octane2 IRIX64 Release 6.5 Flame 2007 (0 Replies)
Discussion started by: dewaraja
0 Replies

10. Shell Programming and Scripting

Alert When a Process Exceeds a CPU Utilization Limit...

Hi EveryOne We run CICS Sofware on our AIX Machine... When ever some Process or Transaction loops it Takes heavy process Usage.. Is there a way that i can Get a alert message or a Message Thrown on to screen when ever a process named "cicsas" uses more that 20%... fo CPU.. I was... (4 Replies)
Discussion started by: pbsrinivas
4 Replies
Login or Register to Ask a Question