Parameter file with changing date

Hi,

I have a trigger file which looks like this abcdefgh_YYYYMMDD.trg The YYYYMMDD is the year, month and the date. So for example today the trigger file would be abcdefgh_20130703.trg similarly tomorrow it would be abcdefgh_20130704.trg

I need to write a script to check if the trigger file exists. If the trigger file does not exists then I have to send a mail stating that Trigger file does not exist and the load cannot start. If the trigger file exists then the rest of the workflow (I am using Informatica) should continue.

Thanks in advance.

Try something like:

#!/bin/ksh
tf="abcdefgh_$(date +%Y%m%d).trg"
if [ ! -f $tf ]
then    echo "$tf does not exist" | mailx -s "missing trigger file" who@where
        echo "$tf missing" >&2
        exit 1
fi
echo 'invoke informatica here'

Hello,

Could you please try the following code.

 
a=`date '+%y:%m:%d' | awk -F":" '{printf"20%2d%2d%2d\n",$1,$2,($3)}' | sed 's/ /0/g'`

#echo $a

tmpfile=abcdefgh_$a
#echo ${tmpfile}
cd /home/singh/awk_prog*
 
if [[ -e ${tmpfile} ]]
then
mailx -s "file exists" Ravinder_Singh1@test.com
else
mailx -s "file does NOT exists" Ravinder_Singh1@test.com
fi

 
 

Note: # is used for commenting the lines/codes. Please try this hopw trhis will help you.

Thanks,
R. Singh