At 6:41 AM +0100 3/18/10, HACKER Nora wrote:
Hi list,
I want to do a 'df' on a diretory on another machine via 'rexec'. I
thought I could do that via the Perl module Filesys::Df, but then I
realized that I can't call a function of a module directly because the
rexec executes a normal shell command. I would have wanted something
like this:
use strict;
use warnings;
use Filesys::Df;
use Net::Rexec 'rexec';
my $df=df("/backup");
my ($rc, @output) = rexec ("myhost", $df); # OUCH!
print "RC: $rc\n";
print "Output: @output\n";
Since this is nonsense that doesn't work, could you please point me in
the right direction how to approach this best? So far, I found two
possible solutions both of which seem very un-Perl to me: Either by
rexec("myhost", 'df -m /backup|tail -1 |awk \'{print $3}\''); or by
executing a separate Perl script which uses the Filesys::Df module.
Try the command
my( $rc, @output ) = rexec('myhost', 'df -m /backup');
and parse the lines in @output to find the desired number. It is
probably the third field of the second line: $output[1], so
(untested):
print (split(' ',$output[1]))[2] . "\n";
--
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]
http://learn.perl.org/