CGI/Perl Guide | Learning Center | Forums | Advertise | Login
Site Search: in

  Main Index MAIN
Search Posts SEARCH
Who's Online WHO'S
Log in LOG

Home: Perl Programming Help: Advanced:
Which process have a file open


New User

Jun 16, 2011, 2:43 AM

Post #1 of 3 (2589 views)
Which process have a file open Can't Post


I have used Linux::Fuser for determining the proceeses using a file.

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. Some features may not work correctly on kernel versions older than 2.6.22.

Thus it is not working in higher kernel version.

Pls. suggest any cpan module or perl function to determine processes using a particular file,so that i can wait for the process to finish to work upn the file.




Jun 16, 2011, 10:59 AM

Post #2 of 3 (2581 views)
Re: [perl123soumen] Which process have a file open [In reply to] Can't Post

Don't double post your questions mate. You've already asked this question:;

- Miller

New User

Jun 17, 2011, 5:50 AM

Post #3 of 3 (2558 views)
Re: [miller] Which process have a file open [In reply to] Can't Post

I have found a soln.;

use Unix::Lsof;

my $CheckUser=&CheckFile($file,$DirPathPMTA);

sub CheckFile

my ($file,$DirPathPMTA)= @_;

my ($output,$error) = lsof(+D,"$DirPathPMTA");

foreach $key (keys %$output)
if(( $output->{$key}->{"command name"} eq "ftp") || ( $output->{$key}->{"command name"} eq "vsftpd"))

my ($output,$error) = lsof("+p",$output->{$key}->{"process id"});

foreach $key (keys %$output)
for my $files ( @{ $output->{$key}{files} } )
if ($files->{"file name"}=~m/$file/s)

return $files->{"file name"};




This checks for file access through ftp before prcoessing starts.

Waiting foe enhancement of the code.



Search for (options) Powered by Gossamer Forum v.1.2.0

Web Applications & Managed Hosting Powered by Gossamer Threads
Visit our Mailing List Archives