script not giving the desired output

Hi,

I have a script in which an entry like this .....

FILENAME_B="PIC_${DATE}0732*.JPG"

The script connects to an ATM and pull a pic file from it.The format for the file is like PIC_2008061400000001.JPG in the ATM.

Means 1st 8 digit is the date(YYYYMMDD) field
2nd 8 digit means hrs min sec millsec
I want only one or two random pic files with in a particular time.

But the above entry can't pick a picfile and i can't give any random name in script.So i give the entry like above. Serve inwhich i wrote this script is an AIX server.

Here's a crufty way to select a random file in a directory:

$ ls | sort -R | sed '1!d'

I'm using gnu's sort (Ubuntu). Good luck!

My issue is while running the script this line is showing error
FILENAME_B="PIC_${DATE}0732*.JPG"
Means i want to repalce the * with seconds from(00 - 60sec)

And also
when i am trying to move the file like this

mv $FILENAME_B EJDATA.$ATMNAME.$DATE.TXT >> $LOGFILE
mkdir $ATMNAME
mv EJDATA.$ATMNAME.$DATE.JPG $ATMNAME >> $LOGFILE

It showing permission error............
Please do you have any idea?