Loop to check for file up to 3 times

Please forgive this I think rather basic question.

I have been away from UNIX for a very long time and am in need of some help.

I need to be able to check for the existance of a specific file name say 'file.dat' in a particular location

If the file exists then run a second process (at processname now)

If the file does not exist then sleep 5 minutes and look for it again for up to 3 times

Once the file has been found and processed once only then send a mail and finish

Any hints tips or specific examples would be appreciated

Running HPUX by the way

Thanks

#!/bin/ksh
file="/path/to/file.dat"

for i in 1 2 3
do
    if [[ -f $file ]] ; then
        echo "file found" | mailx -s "$file found `date`"  joeblow@somewhere.com
        break
    fi
    sleep 300   # five minutes
done 

Start with this.

Many thanks for your help.

I have made some progress using the code, but need some further help with the following

1 The process searches up to 3 times for the arival of a file. Once it has detected the file and processed the job , it is important that it does not do so again. How can I prevent this?

2 In this version of the code the script does not loop back to try again when the file is not found

#!/bin/ksh
file="/path/to/file/file.dat"

for i in 1 2 3
do
if [[ -f $file ]] ; then echo " file found"
at -f jtest_get_file.sh now
else
echo "File not found!".

    break
fi
sleep 3  \# 3 seconds will be 600

done

Regards