Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chris Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Email Notification....

Status
Not open for further replies.

kumariaru

IS-IT--Management
Mar 9, 2006
61
AU
Hi All
I have to send an email if the count of the folder does nt match with what expected.

#!/bin/ksh/
#Sends an email if the count of the files in a folder are less then expected

SrcDir=$1
Count=$2

cd $SrcDir | ls -l | wc -l -ne $Count && mutt -s "The count of $SrcDir is not equal to $Count" test@thehartford.com


This is not working. How can I do it in other way..

Thanks in advance
~
 
What about this ?
[ $(ls $SrcDir | wc -l) -ne $Count ] && mutt -s "The count of $SrcDir is not equal to $Count" test@thehartford.com

Hope This Helps, PH.
FAQ219-2884
FAQ181-2886
 
Try
Code:
#!/bin/ksh/
#Sends an email if the count of the files in a folder are less then expected

SrcDir=$1
Count=$2

[[ $(ls $SrcDir | wc -l) -ne $Count ]] && mutt -s "The count of $SrcDir is not equal to $Count" test@thehartford.com

More readable - and therefore more maintainable
Code:
#!/bin/ksh/
#Sends an email if the count of the files in a folder are less then expected

SrcDir=$1
Count=$2
FileCount=$(ls $SrcDir | wc -l)
if [ $FileCount -ne $Count ]
then
  mutt -s "The count of $SrcDir is not equal to $Count" test@thehartford.com
fi

Ceci n'est pas une signature
Columb Healy
 
Looks like PHV and I were thinking along the same lines - but he was quicker on the keyboard!

Ceci n'est pas une signature
Columb Healy
 
Hi All...
Thanks a lot..
I do nt have "mutt" command on my UNIX. I tried using the mail command instead of mutt& it is not sending a mail..but it is creating a file called dead.letter in default folder...
I used both scripts...

Thanks in advance....
 
You could try;
.
.
if [ $FileCount -ne $Count ]
then
echo "The count of $SrcDir is not equal to $Count" > file1
cat file1 | mailx -s "blah blah" test@thehartford.com

It's a UUOC but it works.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top