Hello,
I have the following script which will look for log files with the current time stamp. Can somebody tell me how to add a condition in the echo statement so that both timestamps will be evaluated and emailed out.
alertUser="myemail@yahoo.com"
now=`date '+%m%d%y'`.txt
now2=`date '+%m%d%Y'`.txt
for i in `cat /apps/opt/tmp/File`
do
if [[ -f /apps/opt/inbox/$\{i\}$now ]] && [[ -f /apps/opt/inbox/$
{i}$now2 ]]
then
echo ${i}$now found > /dev/null
echo ${i}$now2 found > /dev/null
else
echo "$\{i\}$now not found, Please contact Production Support" |
mailx -s "Alert: File not Found" $alertUser
fi
done
Thanks,
Your feedback is greatly appreciated.
Your coded as posted (now=`date '+%m%d%y'`) will simply set the variable $now to be - EG - 091207.txt
It will *not* create a file called 091207.txt.
If all you want to do is include the contents of $now and $now2 in your email then you can do...
echo "${i}$now not found, %now; $now2; Please contact Production Support" |
mailx -s "Alert: File not Found" $alertUser
Please note that as your code stands $now and $now2 will only differ by the time it takes for the script to execute the first and then the second variable assignments. It almost certainly means they will always be set to the same value. This raises the question of why you need two variables rather than one as you say that you are looking for log files with the current (same?) timestamp.