Can anyone help?

I have a print script in bash that monitors a certain folder, when that 
folder is populated with a postscript file it is converted to a pdf and 
then printed to a selected printer.

The problem is that evertime the scripts detects a file it tries to 
open itimmediately even though it is still being created and this 
brings down our file server. Is there a way of placing a "wait until 
the file has been closed by the creator then start processing" the 
script resides below if it is any help.

#!/bin/sh

running=1;
while [ $running -eq 1 ]; do
ls/home/user/workflow/Proofers/A4/*.pdf  2>/dev/null
if [ $? -eq 0 ] ; then
     echo "A4 Files Found!!"
     lp -d brothers /home/user/workflow/Proofers/A4/*.pdf  2>/dev/null
     if [ $? -eq 0 ] ; then
         # Possibly put in a sleep(60) or whatever here so
         # files are not deleted b4 printing
         echo "A4 Files Printed!!"
         rm /home/user/workflow/Proofers/A4/*.pdf 2>/dev/null
     fi
fi
ls/home/user/workflow/Proofers/A3/*.pdf  2>/dev/null
if [ $? -eq 0 ] ; then
     echo "A3 Files Found!!"
     lp -d brothers /home/user/workflow/Proofers/A3/*.pdf  2>/dev/null
     if [ $? -eq 0 ] ; then
         # Possibly put in a sleep(60) or whatever here so
         # files are not deleted b4 printing
         echo "A3 Files Printed!!"
         rm /home/user/workflow/Proofers/A3/*.pdf 2>/dev/null
     fi
fi
done


Lyle Chapman

Pre-Press Supervisor
Torch Publishing Co.
47 Allingham Street, Condell Park 2200, NSW, Australia
612 9795 0000
http://www.torchpublishing.com.au
-- 
SLUG - Sydney Linux User's Group Mailing List - http://slug.org.au/
Subscription info and FAQs: http://slug.org.au/faq/mailinglists.html

Reply via email to