The UNIX and Linux Forums  


Go Back   The UNIX and Linux Forums > Top Forums > Shell Programming and Scripting
.
google unix.com




View Single Post in the UNIX and Linux Forums - Click on the Thread or Permalink to View Entire Thread -->
  #5 (permalink)  
Old 11-19-2008
venkatesht venkatesht is offline
Registered User
  
 

Join Date: Nov 2008
Posts: 69
See the below script:

This is what i have done so far. Thanks in advance.


Code:
Y=`date +'%Y'`
M=`date +'%m'`
D=`date +'%d'`
#today=$Y$M$D
#echo $today

if [ $M -eq 01 -o $M -eq 03 -o $M -eq 05 -o $M -eq 07 -o $M -eq 08 -o $M -eq 10 -o $M -eq 12 ] && [ $D -eq 01 ];then
   yesterday=`expr $D + 30`$M$Y
else
if [ $M -eq 04 -o $M -eq 06 -o $M -eq 09 -o $M -eq 11 ] && [ $D -eq 01 ]; then
   yesterday=`expr $D + 29`$M$Y
else
if [ $M -eq 02 -a $D -eq 01 ]; then
   yesterday=`expr $D + 27`$M$Y
else
   yesterday=`expr $D - 1`$M$Y
fi
fi
fi

find /opt/pkms/sinteg/logs -name "Pk*" -mtime 2 -type f -exec ls -l {} \; > Txtfile

if [ -s Txtfile ];then
   cut -d ' ' -f 6- Txtfile > corefile
fi;

echo "Please find the following corefiles.\n" > EMAIL.txt

#Append the required fields to EMAIL.txt

cat corefile >> /opt/pkms/CGEYScripts/EMAIL.txt

#E-mail output to PKMS Team

mailx -s "corefiles_$yesterday" \Team@mail.com \ < /opt/pkms/CGEYScripts/EMAIL.txt

#if e-mail is successful, delete the files

errflag=$?

if [ $errflag = 0 ]
then
  rm /opt/pkms/CGEYScripts/EMAIL.txt
  rm Txtfile
fi


Thanks,
Venkatesh.

Last edited by vino; 11-19-2008 at 05:56 AM.. Reason: Removed email id from the post