after testing several modules for sending SSH commands with PERL, my choice is for the Net::SSH::Expect module (able to send mutiple commands for a unique connection)
I am still testing some functions on it, here's my code :
use Net::SSH::Expect;
my $user="myuser";
my $host = "126.30.186.249";
my $passwd = "mypasswd";
my $ssh = Net::SSH::Expect->new(host => "$host", password=> "$passwd", user => "$user", raw_pty => 1 );
my $login_output = $ssh->login();
$ssh->send("sh arp");
my $line ;
while ( defined ($line = $ssh->read_line()) ) {
print $line . "\n" ;
}
Here's my issue : When using the "exec" function instead of "send" :
sh arp
Protocol Address Age (min) Hardware Addr Type Interface
Internet 126.30.186.3 112 0080.9f8b.fc1a ARPA GigabitEthernet0/1.186
Internet 126.30.186.6 163 0080.9f8b.fc1a ARPA GigabitEthernet0/1.186
Internet 126.30.186.247 - e4c7.2291.5181 ARPA GigabitEthernet0/1.186
Internet 126.30.186.248 33 885a.9291.c7e1 ARPA GigabitEthernet0/1.186
Internet 126.30.186.249 - 0000.0c07.ac65 ARPA GigabitEthernet0/1.186
Internet 126.30.186.250 - 0000.0c07.ac66 ARPA GigabitEthernet0/1.186
Internet 126.30.187.241 38 0017.e05d.b144 ARPA GigabitEthernet0/1.230
Internet 126.30.187.242 96 0012.dada.65c1 ARPA GigabitEthernet0/1.230
Internet 126.30.187.243 96 f025.7275.63c1 ARPA GigabitEthernet0/1.230
Internet 126.30.187.250 - 0000.0c07.ac00 ARPA GigabitEthernet0/1.230
Internet 126.30.187.251 - e4c7.2291.5181 ARPA GigabitEthernet0/1.230
**--More--**
This "MORE" prompt is a problem. So as you can see, i tried with "send" and made a while loop. The result given is the same, but without the --More-- prompt. I need to skip the "more" prompt and see all the result. Net::OpenSSH is giving me all the result when sending a "capture". I searched for any functions skipping automatically the "more" prompt... But not results :( Can anyone help me on this ? Thanks.