[TriLUG] YAPQ (yet another perl question)..
Tanner Lovelace
clubjuggler at gmail.com
Thu Jun 11 15:11:17 EDT 2009
On Thu, Jun 11, 2009 at 2:20 PM, Greg Brown<gwbrown1 at gmail.com> wrote:
> 15998976 bytes total (358912 bytes free)
So, you're looking for this line..
> my( $which, $why, $match, $before, $after ) = $ssh->expect(30,'#');
>
Using this line, right?
Instead of collecting everything in $before, use the power of perl::Expect
and regular expressions to do something like this:
my $string = "Not found";
$ssh->expect(30,
[ ".*bytes total.*bytes free.*" => sub {
my $self = shift;
$string = $self->match();
exp_continue;
} ],
'#'
);
$string =~ m/([0123456789]+) bytes total.*([0123456789]+) bytes free/;
print "Total bytes: $1\n";
print "Free bytes: $2\n";
My testing seems to suggest this will work much better than what
you're trying to do.
Cheers,
Tanner
--
Tanner Lovelace
http://wtl.wayfarer.org/
(fieldless) In fess two roundels in pale, a billet fesswise and an
increscent, all sable.
More information about the TriLUG
mailing list