to.b has asked for the wisdom of the Perl Monks concerning the following question:
Dear Monks,
In my Perl script I execute an external program via the system() function. Subsequently I process the output file of this program.
This works perfectly on my local machine but fails on NFS terminals because the output file is not readily available when Perl returns after the system() call due to a delay in writing files on this system. My script dies because it cannot open the output file.
To avoid this problem, my program sleeps while the output file doesn't -exist. Unfortunately, this approach is only half-solving my problem because sometimes the output file exists but its content is not written yet. In this case my script dies because the file is empty. To solve this problem again, my first idea was to check if the file is still opened by the external program, but I don't know how to test this with Perl.
What's the preferred way to test for open files? Maybe there's another approach to solve the whole problem? I hope somebody can help me.
Thanks in advance
to.b
P.S: I use Perl 5.6.1 on UNIX.
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Waiting for delayed output after system()
by Zaxo (Archbishop) on May 06, 2004 at 14:42 UTC | |
by to.b (Initiate) on May 06, 2004 at 14:55 UTC | |
|
Re: Waiting for delayed output after system()
by Joost (Canon) on May 06, 2004 at 14:41 UTC | |
|
Re: Waiting for delayed output after system()
by ozone (Friar) on May 06, 2004 at 15:11 UTC | |
|
Re: Waiting for delayed output after system()
by bluto (Curate) on May 06, 2004 at 15:48 UTC | |
|
Re: Waiting for delayed output after system()
by dave_the_m (Monsignor) on May 06, 2004 at 15:18 UTC |