Hi All,
So.. I am trying to do a simple script copy task and need a second pair of eyes please as i cannot get it working..
My goal is to set a cron task to run a script once a day and copy the newest file (pdf reports automatically created daily) from folderA (MY_DIR) to folderB (DEST) on the R80.10 CMA (logged in as admin)
---------------------------------------------
#!/bin/bash
MY_DIR="/var/tmp/"
DEST="/home/admin/"
FILEEXT="pdf"
NEWEST=`ls -tr1d "${MY_DIR}"*.${FILEEXT} | tail -1`
if [ -z "${NEWEST}" ] ; then
echo "No file to copy"
exit 1
else
echo "Copying ${NEWEST}"
cp -p "${NEWEST}" "${DEST}"
fi
---------------------------------------------
but when running the script i get the following error..
[Expert@CMA:0]# ./sascopy.sh
Copying ls -tr1d "${MY_DIR}"=*.${FILEEXT} | tail -1
cp: cannot stat `ls -tr1d "${MY_DIR}"=*.${FILEEXT} | tail -1': No such file or directory
[Expert@CMA:0]#
If I run 'ls -tr1d /var/tmp/ | tail -1' manually I can see the file and output is the full dir listing.
I suspect this line here to be the problem..
NEWEST=`ls -tr1d "${MY_DIR}"*.${FILEEXT} | tail -1`
thanks in advance
ants