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 derfloh on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

unix script help required

Status
Not open for further replies.

toronto2003

IS-IT--Management
May 5, 2003
14
CA
Hello,

I need help writing a unix script and then have it as a cronjob running everyday at 6:00 a.m

There are three .csv files that get generated every day via other job on \disk2\jobs directory:

The files under this directory end with the current date:
A_YYYYMMDD.csv
B_YYYYMMDD.csv
C_YYYYMMDD.csv

I need to do a record count on all these three .csv files and send an email along with the attachments to an email alias. I also need to send an alert if either of this three files are not found in the /disk2/jobs directory at 6:00 a.m every day.

Your help on this would be highly appreciated.

Thanks a lot.
 
Hello,

Below mentioned is the main body of my script. I need to add the different subject for "Completed" and "Failed" depending whether the file is found or not.

The curent version is just showing one subject "Results" for both failed and completed.

Where should I embedd the different subject logic in this script.
######################################################
dt0=400
for i in $ls $lr $ms $mr $rs $rr
do
if [ ! -f $my_dir/$i ]
then
print "File $my_dir/$i not found!\n"
else
fndt=`ls -l $my_dir/$i |awk '{print $8;}'`
dth=`echo $fndt |cut -f 1 -d':'`
dtm=`echo $fndt |cut -f 2 -d':'`
dt=`expr ${dth} * 100 + ${dtm}`
if [ $dt -gt $dt0 ]
then
print "File $my_dir/$i not found!\n"
else
print "File $my_dir/$i present with $(cat $i|wc -l) records."
fi
fi
done
print
) | mailx -s "Results:" ${maildest}
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top