The UNIX and Linux Forums  
Hello and Welcome from United States to the UNIX and Linux Forums! Thank You for Visiting and Joining Our Global Community.

Go Back   The UNIX and Linux Forums > Top Forums > UNIX for Dummies Questions & Answers
.
google unix.com



UNIX for Dummies Questions & Answers If you're not sure where to post a UNIX or Linux question, post it here. All UNIX and Linux newbies welcome !!

More UNIX and Linux Forum Topics You Might Find Helpful
Thread Thread Starter Forum Replies Last Post
Problem with Cron Email Notification sasaliasim AIX 1 04-29-2008 12:02 PM
Alert When a Process Exceeds a CPU Utilization Limit... pbsrinivas Shell Programming and Scripting 4 06-20-2007 08:38 AM
How to add email notification in scripts? redlotus72 UNIX for Dummies Questions & Answers 2 03-14-2005 08:19 AM
Why am I not recieving email notification? Kelam_Magnus Post Here to Contact Site Administrators and Moderators 6 09-03-2002 10:01 PM
email notification if job is killed/dies jacob_gs Shell Programming and Scripting 2 05-15-2002 02:29 PM

Closed Thread
English Japanese Spanish French German Portuguese Italian Dutch Swedish Russian Norwegian Hungarian Hebrew Danish Bulgarian Greek Powered by Powered by Google
 
LinkBack Thread Tools Search this Thread Rate Thread Display Modes
  #1 (permalink)  
Old 07-07-2006
amitsayshii amitsayshii is offline
Registered User
  
 

Join Date: Jun 2006
Location: JHB
Posts: 18
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 08:11 AM..
  #2 (permalink)  
Old 07-07-2006
blowtorch's Avatar
blowtorch blowtorch is offline Forum Advisor  
Supporter
  
 

Join Date: Dec 2004
Location: Singapore
Posts: 2,350
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 (permalink)  
Old 07-07-2006
amitsayshii amitsayshii is offline
Registered User
  
 

Join Date: Jun 2006
Location: JHB
Posts: 18
Yes it runs fine also the no of files returned is correct. Its just that the condition is not getting checked. Thanks
  #4 (permalink)  
Old 07-07-2006
matrixmadhan matrixmadhan is offline Forum Advisor  
Technorati Master
  
 

Join Date: Mar 2005
Location: leaf node in B+ tree
Posts: 2,953
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 (permalink)  
Old 07-07-2006
amitsayshii amitsayshii is offline
Registered User
  
 

Join Date: Jun 2006
Location: JHB
Posts: 18
If I do echo $file_length I get the value.Correct me if I am not getting it...thanks
  #6 (permalink)  
Old 07-07-2006
blowtorch's Avatar
blowtorch blowtorch is offline Forum Advisor  
Supporter
  
 

Join Date: Dec 2004
Location: Singapore
Posts: 2,350
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.
Closed Thread

Bookmarks

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On




All times are GMT -4. The time now is 02:43 AM.


Powered by: vBulletin, Copyright ©2000 - 2006, Jelsoft Enterprises Limited. Language Translations Powered by .
vBCredits v1.4 Copyright ©2007 - 2008, PixelFX Studios
The UNIX and Linux Forums Content Copyright ©1993-2009. All Rights Reserved.Ad Management by RedTyger

Content Relevant URLs by vBSEO 3.2.0