![]() |
Hello and Welcome from United States to the UNIX and Linux Forums! Thank You for Visiting and Joining Our Global Community.
|
|
google unix.com
|
|||||||
| Forums | Register | Forum Rules | Links | Albums | FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read |
| Shell Programming and Scripting Post questions about KSH, CSH, SH, BASH, PERL, PHP, SED, AWK and OTHER shell scripts and shell scripting languages here. |
More UNIX and Linux Forum Topics You Might Find Helpful
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| help me in sending parameters from sqlplus script to unix shell script | Hara | Shell Programming and Scripting | 2 | 01-29-2008 03:31 PM |
| Checklist for Shell Script reqd | Shivdatta | Shell Programming and Scripting | 2 | 11-30-2007 10:59 AM |
| check in unix shell script so that no one is able to run the script manually | adi_bang76 | Shell Programming and Scripting | 1 | 11-16-2006 10:43 AM |
| Difference between writing Unix Shell script and AIX Shell Scripts | haroonec | AIX | 0 | 04-12-2006 02:27 AM |
| How to run unix commands in a new shell inside a shell script? | hkapil | Shell Programming and Scripting | 2 | 01-04-2006 06:56 AM |
![]() |
|
|
LinkBack | Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
||||
|
unix shell script reqd...
Task:
Short Description: To find the files in a particular directory for the previous day, sort them by date and time and e-mail it across to a particular id. And the time is divided into eight fields and based on the time the respective field should be updated with the flag 1. Eight fields look like (12 to 15, 15 to 18, 18 to 21, 21 to 24, 00 to 03, 03 to 06, 06 to 09 and 09 to 12) And finally the total column should be updated with the no of files that belong to the same type. Please find the attached excel sheet. Needs to send the attachment in this format to users. Thanks in advance, Venkatesh. |
|
||||
|
I didn't get your question. I have prepared a script where it does finding the files in a directory for the previous day and e-mail it across to the respective users.
But i need to prepare a script where based upon time field the flag should be update with 1. Explained clearly this point. Please help. Thanks, Venkatesh. |
|
||||
|
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 |
![]() |
| Bookmarks |
| Tags |
| shell script, shell scripting, unix scripting, unix scripting basics |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|