Unix::LsofWrapper to the Unix lsof utility | |
Download |
Unix::Lsof Ranking & Summary
Advertisement
- License:
- Perl Artistic License
- Price:
- FREE
- Publisher Name:
- Marc Beyer
- Publisher web site:
- http://search.cpan.org/~marcb/
Unix::Lsof Tags
Unix::Lsof Description
Wrapper to the Unix lsof utility Unix::Lsof is a Perl wrapper around the Unix lsof utility (written by Victor A.Abell, Copyright Purdue University), which lists open files as well as information about the files and processes opening them. Unix::Lsof uses the lsof binary, so you need to have that installed in order to use this module (lsof can be obtained from ftp://lsof.itap.purdue.edu/pub/tools/unix/lsof).By default, this module exports a single function lsof, to which you can pass the same parameters you would the lsof binary. When called in list context, lsof will return two values, a hash reference containing the parsed output of the lsof binary and a string containing (unparsed) any error messages. When called in scalar context, lsof will return a Unix::Lsof::Result object (see the documentation for that module for further details).On request, you can also export the subroutine parse_lsof_output which will do what the name says and return the parsed output. Both of these support a number of options, passed in as a hash reference as the last argument (see section "OPTIONS" below).SYNOPSIS use Unix::Lsof; my ($output,$error) = lsof("afile.txt"); my @pids = keys %$output; my @commands = map { $_->{"command name"} } values %$output; ($output,$error) = lsof("-p",$$); my @filenames; for my $pid (keys %$output) { for my $files ( @{ $o->{$k}{files} } ) { push @filenames,$f->{"file name"} } } my $lr = lsof ("-p",$$); # see Unix::Lsof::Result @filenames = $lrs->get_filenames(); @inodes = $lrs->get_values("inode number"); # With options my $lr = lsof ("-p",$$,{ binary => "/opt/bin/lsof" }); Requirements: · Perl
Unix::Lsof Related Software