Hi Lee
You can use Net::SSH2 or Net::SSH::Perl to log into your switches and run any
commands you need to. I actually use Net::SSH2 for this...There are a lot of
examples around.
You just need to do something like this...
This code is only an example.
my $ssh2 = Net::SSH2->new();
$ssh2->connect( $YOURSERVERHERE); # can be ip or fqdn or just the device name
is if it has an entry in dns
$ssh2->auth_password($USERNAME_TO_SWITCH, $PASSWORD);
$channel = $ssh2->channel();
$channel->exec($YOUR_CMD_HERE);
while ($channel->read($buf, $buflen)) {
$result .=$buf;
}
Then you have to parse what you get back.
Here is a link to stack overflow with an example to using Net::SSH::Perl which
looks a bit easier.
http://stackoverflow.com/questions/16594963/perl-ssh-into-device
Trac
-----Original Message-----
From: lee [mailto:[email protected]]
Sent: Tuesday, July 12, 2016 7:33 PM
To: [email protected]
Subject: Re: configure a switch via ssh with a perl program
Shekar <[email protected]> writes:
> Hi Lee,
>
> If you can login to your switch via ssh, run required commands on the
> switch and exit out, you should be able to simulate the same via
> Net::OpenSSH or Net::SSH::Perl
Yes, that's what I was thinking. Only it takes time to program, that's a
problem.
--
To unsubscribe, e-mail: [email protected] For additional commands,
e-mail: [email protected] http://learn.perl.org/
--
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]
http://learn.perl.org/