unix shell script reqd...


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting unix shell script reqd...
# 1  
Old 11-18-2008
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.
# 2  
Old 11-18-2008
where is your problem? show us what you have done so far in your script.
# 3  
Old 11-19-2008
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.
# 4  
Old 11-19-2008
so show us what you have done so far. nobody is writing a script for you. we can help if you are stuck...
# 5  
Old 11-19-2008
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
# 6  
Old 11-20-2008
Can anyone help me on this please?

Thanks,
Venkatesh.
# 7  
Old 11-20-2008
please don't "bump" up posts. it's against the rules. if anyone can help, they will... just wait a bit!
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

How can i run sql queries from UNIX shell script and retrieve data into text docs of UNIX?

Please share the doc asap as very urgently required. (1 Reply)
Discussion started by: 24ajay
1 Replies

2. Shell Programming and Scripting

FTP from windows to unix server using unix shell script

Hi, Is it possible to ftp a huge zip file from windows to unix server using unix shell scripting? If so what command i need to use. thanks in advance. (1 Reply)
Discussion started by: Shri123
1 Replies

3. Shell Programming and Scripting

Explanation reqd for the Unix file

Hi, I have a unix file with the following contents #/usr/bin/sh cd /ct/mr/prod/bin ncm_AdjCob.pl -a /ct/mr/prod/wg/applog_AdjDev.log -c /ct/mr/prod/lib/config/bcmp_AdjDevCob.conf -s /ct/mr/prod/log/syslog can anyone explain what it says. particularly -a ,-c... (5 Replies)
Discussion started by: psthariharan
5 Replies

4. Shell Programming and Scripting

Help reqd in shell scripting..

Hi guys, I am new to shell scripting and I need urgent assistance. I have an xml like : <AgreementNumberFull>13-WY-84252</AgreementNumberFull> <AgreementNumberAbbr>WY84252</AgreementNumberAbbr> <LineOfBusiness>F</LineOfBusiness> <CompanyCode>0005</CompanyCode> <UniqDigit/> <StateCode/> ... (9 Replies)
Discussion started by: puneetkanchi
9 Replies

5. Shell Programming and Scripting

Shell Script - help Reqd

Hi, I need someone's help in writing a shell script. Since am very new i am stuck . I have 2 files in the same dir. ============================================== FileA Table1~07/07/2009 00:00:00~4 Table1~07/06/2009 00:00:00~41 Table1~07/08/2009 00:00:00~4 ... (8 Replies)
Discussion started by: vijayarajvp
8 Replies

6. Shell Programming and Scripting

shell script reqd - deleting files

I have written a script that deletes files: Requirement: i need to delete the files and to know how many files are deleted i.e the count of files and even i need to display when the started time of deletion and the ending time of deletion. I need to display these two times. script: ... (2 Replies)
Discussion started by: venkatesht
2 Replies

7. Shell Programming and Scripting

Checklist for Shell Script reqd

Hi, Can anyone provide me with the Code Review Checklist for Shell scripts ?? Thanks in advance. (2 Replies)
Discussion started by: Shivdatta
2 Replies

8. HP-UX

Help Reqd

Hi I am facing the problem where my HP Unix system date is in accordance with the current date but the logs written by the same is of previous time stamp. Eg. System Date - Thu Mar 15 18:00:04 IST 2007 Syslogs - Mar 15 12:30:10 mac@1 ftpd: FTP LOGIN FROM xx.xxx.xxx.xx , main The ftp... (1 Reply)
Discussion started by: PradeepRed
1 Replies

9. AIX

Difference between writing Unix Shell script and AIX Shell Scripts

Hi, Please give me the detailed Differences between writing Unix Shell script and AIX Shell Scripts. Thanks in advance..... (0 Replies)
Discussion started by: haroonec
0 Replies

10. Shell Programming and Scripting

How to run unix commands in a new shell inside a shell script?

Hi , I am having one situation in which I need to run some simple unix commands after doing "chroot" command in a shell script. Which in turn creates a new shell. So scenario is that - I need to have one shell script which is ran as a part of crontab - in this shell script I need to do a... (2 Replies)
Discussion started by: hkapil
2 Replies
Login or Register to Ask a Question