edimusrex has asked for the wisdom of the Perl Monks concerning the following question:
I am attempting to use Net::SSH2::Cisco to issue a command to a Cisco phone server. It's not an issue if it's a command which doesn't require any kind of confirmation but if it does I can't seem to get it right. Here is what I am trying to do
#!/usr/bin/perl use warnings; use strict; use Net::SSH2::Cisco; my $host = '<my_host>'; my $user = '<my_user>'; my $password = '<my_password>'; my $session = Net::SSH2::Cisco->new(host => $host); $session->login(username => $user, password => $password); my $match = '/^.+\[(confirm)\]/'; my $command = 'service-module integrated-Service-Engine 0/0 shutdown'; my @config = $session->cmd(String => $command, Prompt => $match); $session->close; print @config;
If I go and check the status of the service module it has not been issued a shutdown command but the script completes without any errors or warnings
Any help would be greatly appreciated
Thanks in advice
----- UPDATE -----
I figured it out, it was pretty simple. Here's all I had to do
#!/usr/bin/perl use warnings; use strict; use Net::SSH2::Cisco; my $host = '<my_host>'; my $user = '<my_user>'; my $password = '<my_password>'; my $session = Net::SSH2::Cisco->new(host => $host); $session->login(username => $user, password => $password); my @config = $session->cmd("service-module integrated-Service-Engine 0 +/0 shutdown\n\n\n"); $session->close; print @config;
I didn't actually have to look for a prompt I just needed to send enter to the command line
Thanks for reading
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Net::SSH2::Cisco Question, help with prompts
by VinsWorldcom (Prior) on Jul 26, 2016 at 17:30 UTC | |
by edimusrex (Monk) on Jul 26, 2016 at 17:44 UTC | |
by VinsWorldcom (Prior) on Jul 26, 2016 at 20:42 UTC |