Perl Net::SSH2 read call never returns

Hi,
I am trying to scrape the output from 'show cdp neighbor interface <interface> det' for a list of ports, in Perl.
For some reason the read call never returns, causing everything to halt after the first entry in the list has been processed.

The device i am trying to scrape has paging disabled.
Any idea what this could be?
Perl:
my $channel = $ssh->channel();
      $channel->shell;
my @ports = ("Gi1/0/1","Gi1/0/2");
foreach my $port (@ports){
         print $channel "sh cdp nei $port det\n";
        while (my $line = <$channel>){
                         #Do stuff
                              .
                              .
            #This never returns
        }
}
 
Your code assumes that my $channel = $ssh->channel(); is always successful, which may not be the case. The code that sets $ssh is missing, this may or may not have been successful too.
 
Hi,
Yes i am aware that any error handling is missing at this point.
However the first iteration runs successfully.

Perl:
if ($line =~m/\ADevice ID:\s(.*)/){
            $deviceid = "$1" if defined $1;
            print "$deviceid\n";
}
 
The loop:
Code:
while (my $line = <$channel>){
                         #Do stuff
                              .
                              .
            #This never returns
        }
Only stops when it receives an EOF. It would only receive that if the connection got closed.
 
Back
Top