in reply to looking for perl module which returns if a file is open

Do you mean something like the command fuser? If so, there is a module on CPAN called Linux::Fuser:

This module provides information similar to the Unix command 'fuser' about which processes have a particular file open. The way that this works is highly unlikely to work on any other OS other than Linux and even then it may not work on other than 2.2.* kernels.

It should also be borne in mind that this may not produce entirely accurate results unless you are running the program as the Superuser as the module will require access to files in /proc that may only be readable by their owner.

Added: If you need instead to parse the output of lsof, use the -F flag that will force the program to produce its output in a format parseable by other programs.

HTH, Valerio

  • Comment on Re: looking for perl module which returns if a file is open

Replies are listed 'Best First'.
Re: Re: looking for perl module which returns if a file is open
by gellyfish (Monsignor) on Jul 03, 2003 at 10:07 UTC

    As author of Linux::Fuser I would be interested to know whether anyone has had any success with it on an OS version other than that stated in the README. Let me know at the address in the README if you have. Cheers.

    /J\