The big question is "What's writing the file?"
If it's a samba share for instance, or a samba printer queue you should do
"man smb.conf" and search for "print command".
Other things that can be done, have the app touch another file when
finished like filename.pdf.go
Your polling routine might look like this:-
while [ 0 ]; do
for TAG in *.go; do
PDF=`echo "$TAG" | sed -e "s/\.go$//"`
process $PDF
rm $PDF $TAG
done
sleep 10
done
Or a more complex answer would be to write a quick program using fam (see
man fam).
On Fri, 5 Mar 2004, Lyle Chapman wrote:
> 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
>
--
---<GRiP>---
Electronic Hobbyist, Former Arcadia BBS nut, Occasional nudist,
Linux Guru, SLUG/AUUG/Linux Australia member, Sydney Flashmobber,
BMX rider, Walker, Raver & rave music lover, Big kid that refuses
to grow up. I'd make a good family pet, take me home today!
Do people actually read these things?
--
SLUG - Sydney Linux User's Group Mailing List - http://slug.org.au/
Subscription info and FAQs: http://slug.org.au/faq/mailinglists.html