On Monday 10 December 2007 05:59, sunckell wrote:
>
> Hey group,

Hello,

>    Hope everyone had a great weekend.  I was working on a perl
> wrapper around the lsof command.  On the AIX machines I work on the
> version of lsof does not display the file name, only the node.  So I
> thought I would write a small wrapper around lsof that does a find on
> the inode (with the volume specifically given as a command line
> option.) Anyways, I used find2perl to generate the the relative find
> code, but I can't seem to find a way to pass a variable to it.

You can't pass a variable to it, nor does it return anything.


open L, '-|', $lsof, $volume or die "Cannot open $lsof:$!\n";

while ( <L> ) {

    if ( /^COMMAND/ ) {
        print "COMMAND\tPID\tUSER\tINODE\t\tFILE\n";
        }
    else {
        my ( $command, $pid, $owner, $node ) = ( split )[ 0, 1, 2, 7 ];
        print "$command\t$pid\t$owner\t[$node]\t\t\n";

        my @names;
        find( sub {
            my $ino = ( lstat )[ 1 ];
            push @names, $_ if -f _ && $ino == $node;
            }, $mount );
        }
    }

close L or warn $! ? "Error closing $lsof pipe: $!"
                   : "Exit status $? from $lsof";



John
-- 
use Perl;
program
fulfillment

-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
http://learn.perl.org/


Reply via email to