I'm very new to bash scripting, so I might be barking up the wrong tree, but here is my current situation:

In a script, I start soffice; to convert an odt to a pdf

It seems that soffice detaches itself from the script's process, and wanders off to do its own thing.. Okay, that's fine; GUI apps tend to do that ...

However I need to wait until the new pdf has been fully written, as my next step involves processing that new pdf.

(As far as I know) I can't utilize soffice's process-ID, because it may have already been a running process before my script started: eg. soffice may be already open for normal GUI activity for another unrelated document/presentation/spreadsheet.

The crux of the matter for me is that before I can proceed, the writing of the new pdf must be finalized...

Is there some way to determine when a file is no longer open to another process in "write" mode? ...

This runs while a process 'pyhton3.2' has got the file 'test.py' opened. As soon as the file is closed, it moves on to 'echo done' and exits.

I've put 'sleep 0.5' in there so that the loop doesn't hog the CPU all that badly. Otherwise, it will use 100% cpu.

Bonus
There seems to be an easy way to convent odt to pdf:

Thanks to scls19fr on the OOo Forum
for this lovely tip. You can convert
OpenOffice Writer files to PDF from
the command line using unoconv -f pdf
input.odt To get unoconv, simply run
sudo apt-get install unoconv at the
terminal.
(rhyshale of rhyshale.wordpress.com)

Wrap this in an until loop and you've got a deal.
–
Nick PascucciNov 21 '10 at 5:36

Done that. :-) I hope it's not terrible style - haven't bothered to read up on best practices. It works well anyway.
–
Stefano Palazzo♦Nov 21 '10 at 6:25

Thanks Stefano... yes, it does work... so it is a good and correct answer.. One a side note, it has highlighted that what is happening in soffice is not as I thought.. It seems that a temporary file is being created and the final file is (perhaps/probably) renamed upon completion... So I'm now looking at that... in which case, I may just need to wait for its *existance... ... and thanks for the link on unoconv .. I'll look into it.. (overall, I'm converting .pdf to multiple ..jpegs one per page)
–
Peter.ONov 21 '10 at 6:56

@fred.bear to wait until a file exists, replace the if-statement with this: if [ -f test.odf ]. (bash script can be so cryptic sometimes...)
–
Stefano Palazzo♦Nov 21 '10 at 15:19