Beefy Boxes and Bandwidth Generously Provided by pair Networks
go ahead... be a heretic
 
PerlMonks  

Login to BGP via Perl

by varalaxmibbnl (Acolyte)
on Jul 13, 2014 at 05:30 UTC ( [id://1093405]=perlquestion: print w/replies, xml ) Need Help??

varalaxmibbnl has asked for the wisdom of the Perl Monks concerning the following question:

Hi Monks

I want to login to bgp to run few commands often so i thought of making script to run those commands and i used

Net::SSH::Perl

to login to bgp and run a command..the script is as follows

#!/usr/bin/perl use Net::SSH::Perl; use POSIX qw(strftime); $time = strftime "%d-%b-%Y", localtime; $host = "XXX.XXX.XXX.XXX"; $username = "user"; $password = "password"; $port = "XXXX"; $ssh = Net::SSH::Perl->new($host,port=>"$port",protocol=>2); @array = $ssh->login($username,$password); #@ary = $ssh ->cmd("show arp"); @data = $ssh->cmd("show interfaces"); print "@array\n@data\n"; @data2 = $ssh ->cmd("exit"); print "@data2\n";

if i run the above script it will login but it prints invalid command show

please some one suggest how to solve this problem

Thanks in advance

Replies are listed 'Best First'.
Re: Login to BGP via Perl
by AppleFritter (Vicar) on Jul 13, 2014 at 11:57 UTC

    Just to get the obvious out of the way: the commands you're issuing are working when you log in manually as the same user?

    Either way I have a hunch it's unlikely that Perl's the culprit here; it's more likely it's down to environment settings of some sort. Perhaps try giving yourself an interactive shell ($ssh->shell; see the Net::SSH::Perl documentation) instead and investigate what's different there compared to a "direct" login using ssh(1).

Re: Login to BGP via Perl
by LanX (Saint) on Jul 13, 2014 at 09:16 UTC

      Yes, they mean is they're trying to control a router via SSH connection.

        yes but through scripting if i do ssh and run commands i get invalid command ..now please let me know how to login to bgp via perl and run those commands

      yes..how do i login to bgp to run commands via perl

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: perlquestion [id://1093405]
Approved by kevbot
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others surveying the Monastery: (3)
As of 2024-04-19 23:42 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found