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


In reply to Net::SSH2::Cisco Question, help with prompts by edimusrex

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.