Before I begin I have posted a similar question to the following https://serverfault.com/questions/873672/custom-prompt-using-netappliancesession

So what I am trying to do is create a custom login prompt for my cisco smart switch. The prompt expected for the username/password is

User Name: Password:

So I've created the following prompt file containing :
prompt username match /User Name/ prompt password match /Password/

My script code looks like this :

#!/usr/bin/perl use warnings; use strict; use Net::Appliance::Session; my $host = '<my_host>'; my $user = '<my_user>'; my $pass = '<my_pass>'; my $session = Net::Appliance::Session->new({ add_library => '/home/edunn/switch', personality => 'custom', transport => 'SSH', host => $host, connect_options => { opts => [ '-q', ], }, }); $session->set_global_log_at('debug'); $session->connect($user,$pass ) or die "Cannot Connect! : $!"; my @output = $session->cmd('show version'); $session->close; print join("\n",@output);

When I run the script I get the following error

[0.001442] p finding prompt [0.006910] t creating Net::Telnet wrapper for ssh [0.007164] t command expands to: ssh -o StrictHostKeyChecking=n +o -o UserKnownHostsFile=/dev/null -o CheckHostIP=no -q 192.168.2.17 [1.349082] d SEEN: [1.364935] p reading phrasebook /home/edunn/switch/custom/login [1.365581] p storing prompt username [1.366753] p storing prompt password [1.367592] p nope, doesn't (yet) match password [1.367821] p nope, doesn't (yet) match username [1.368008] p no match so far, more data? [1.368295] d SEEN: [1.368446] p nope, doesn't (yet) match password [1.368690] p nope, doesn't (yet) match username [1.368877] p no match so far, more data? [1.384701] d SEEN: User Name: [1.384963] p nope, doesn't (yet) match password [1.385179] p hit, matches prompt username [1.385931] p prompt has been set to (?-xism:User Name) unknown prompt [prompt] at /usr/share/perl5/vendor_perl/Net/CLI/Intera +ct/Phrasebook.pm line 53 Net::CLI::Interact::Phrasebook::prompt('Net::CLI::Interact::Ph +rasebook=HASH(0x3665390)', 'prompt') called at /usr/share/perl5/vendo +r_perl/Net/CLI/Interact/Role/Prompt.pm line 48 Net::CLI::Interact::Role::Prompt::prompt_looks_like('Net::CLI: +:Interact=HASH(0x329dc78)', 'prompt') called at /usr/lib64/perl5/vend +or_perl/Moose/Meta/Method/Delegation.pm line 108 Net::Appliance::Session::prompt_looks_like('Net::Appliance::Se +ssion=HASH(0x31d6d30)', 'prompt') called at /usr/share/perl5/vendor_p +erl/Net/Appliance/Session/Transport.pm line 58 Net::Appliance::Session::Transport::connect('Net::Appliance::S +ession=HASH(0x31d6d30)', 'cisco', 'uzf1IgENudObn759sJ9U') called at . +/switch.pl line 21

If I am looking at this correctly it appears to be successfully identifying the User Name and the Password prompts but dies at unknown prompt prompt at /usr/share/perl5/vendor_perl/Net/CLI/Interact/Phrasebook.pm line 53. No sure what the expected value prompt is or where it is coming from.

As always, any and all help will be greatly appreciated

**** UPDATE ****

I ended up updating the firmware to the switch which added the ability for user authenticated ssh so I no longer have the need to look for quirky prompts and can now use the Net::Appliance::Session module without a hitch. Thank you all for suggestions.


In reply to Custom prompts for Net::Appliance::Session 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.