On 28 maj 2006, at 01.34, David Cantrell wrote:

On Sun, May 28, 2006 at 12:27:02AM +0200, Tommy Nordgren wrote:

My perl script generates pdf files, and opens them with Acrobat.
How can I wait until Acrobat closes the file, so I can delete it?

    system('acroread', 'myfile.pdf');
    unlink('myfile.pdf');

        There is no 'acroread' , at least not with only the reader installed
if instead you're doing something like ...

    system('open', '/Applications/Acrobat.app');

then you'll need to:

wait around until Acrobat appears in the process table;
wait around until that PID disappears;

        1. Acrobat may already be running when told to open a document.
2. I would prefer being able to remove the file as soon as it is closed, keeping the reader
running is preferable, since it has long start up time.
        
Will it work to:
a) Wait until Acrobat Reader is running
b) Sleep long enough to make sure acrobat has opened the file
c) Open the file in read/write mode, and wait until a write lock can be aquired
d) Then , close and remove the file
Check out Mac::Processes on the CPAN.

--
David Cantrell | random organic glop and a metric fuckton of electricity

    Wow, my first sigquoting! I feel so special now!
        -- Dan Sugalski

------------------------------------------------------
"Home is not where you are born, but where your heart finds peace" -
Tommy Nordgren, "The dying old crone"
[EMAIL PROTECTED]


Reply via email to