find, remove, and ftp......

I have a script that is run each night by cron. This script generates an extract then places it into an 'extracts' folder and also ftp's a copy to another server.

I have set up the script to remove any files in the extracts folder greater than 28 days old (this occurs each time the script is run). This is the command.

find ${WORKdir}/extracts/ -mtime +29 -exec rm {} \; &&

Now I also want this function to occur in the folder on the other server - preferably using ftp. Here is the ftp activity I already have.

if [ -s ${EXTfile} ]
then
ftp -n ${FTPserver} << cmd
user ${FTPid} ${FTPpwd}
cd ${FTPlocation}
lcd ${WORKdir}/extracts
put ${SHORTfile}
quit
cmd
fi

Can FTP do anything like this - by using unix commands somehow?

You could create a file of the filenames you have deleted on your local host & then use a script to create a list of commands for ftp

eg. (filelist is the list of deleted files)

echo user ${FTPid} ${FTPpwd} > ftpfile
for name in `cat ${WORKdir}/extracts/filelist `
{
echo delete $name >> ftpfile
}
echo quit >> ftpfile

you can then do

ftp -n ${FTPserver} < ftpfile

to delete them

you'll have to use the absolute file names in the example above.