Code:
#!/bin/ksh
if [ -r ftp.pid ]
then
echo previous invocation still running
exit
fi
echo $$ >ftp.pid
ftp A <<EOF >A.list
user
password
ls
quit
EOF
./createnewlist.ksh <A.list >new.list
sleep 10
ftp A <new.list
rm ftp.pid
If you can use .netrc files to store the userid and password, the script to compare the list of files on A and the ones that you already have will be simpler, and you will not have to put the userid and password in the new.list file.
The sleep for 10 seconds should allow any files that are being created while you are listing them to complete by the time you go back to get them.
Your application process should append files that you have successfully processed to your done list, giving you an opportunity to re-retrieve any files that did not process the first time.
createnewlist.ksh should look like:
Code:
#!/bin/ksh
rm new.list
while read perms x own size month day time file
do
grep $file done.list
if [ $? != 0 ]
then
echo get $file >>new.list
fi
done<A.list
echo quit >>new.list
You may have to add additional reads or logic depending on the actual contents of A.list