[Ssh-sftp-perl-users] Net::SSH:Perl register_handler problem
Brought to you by:
dbrobins
|
From: LOYER I. - R. <isa...@at...> - 2004-06-28 16:41:53
|
Hello,
I use the "Net::SSH:Perl 1.25" module to connect to a host and execute
an interactive command.
For that, I use register_handler like this :
$session->register_handler("stdout", sub {
my($channel, $buffer) = @_;
my $str = $buffer->bytes;
if ($str eq "Protocol[ip]:") {
$channel->send_data("ip"."\n");
}
elsif ($str eq "Repeat count[5]:") {
$channel->send_data($repeat."\n");
}
elsif ($str eq "Sweep range of sizes[n]:") {
$channel->send_data("n"."\n");
}
});
my($out, $err)=('','');
($out, $err) = $session->cmd($command);
print $err;
But, the problem is the buffer I received is not exactly what I am
testing.
I would like to use a fonction to search a string in the buffer (like
index).
Is it possible???
I have also an error on the last line "Use of uninitialized value in
print".
I thought I had initialized $err with the line :
my($out, $err)=('','');
What am I doing wrong???
Thanks in advance.
|