Beefy Boxes and Bandwidth Generously Provided by pair Networks
Just another Perl shrine
 
PerlMonks  

Re: Net::SSH2::Cisco and Nexus switches

by VinsWorldcom (Prior)
on Aug 14, 2018 at 20:47 UTC ( #1220345=note: print w/replies, xml ) Need Help??


in reply to Net::SSH2::Cisco and Nexus switches

I wrote Net::SSH2::Cisco but never had Nexus switches to test on. It could be a lot of things, including the prompt string. From the CRAPPS utility I wrote:

... has an issue with prompt discovery on new Cisco IOS-XR routers. These routers have a prompt like: RP/0/RP1/CPU0:routername# The current Net::Telnet::Cisco prompt matching will not catch this and cause timeouts on Telnet connects to these types of routers. This script sends a new prompt that should match existing prompts and the new IOS-XR prompts. If you are having failed connect issues when in Telnet mode, but logging shows that you are connecting, the custom prompt is the first place to look. Net::Telnet::Cisco supplied prompt: '/(?m:^[\w.-]+\s?(?:\(config[^\)]*\))?\s?[\$#>]\s?(?:\(enable\)) +?\s*$)/' Updated by this program: (?:[\w.\/]+\:)? inserted after the "'/(?m:^" The rest of the line is left as is.

Note that I wrote Net::SSH2::Cisco as a drop in replacement for Net::Telnet::Cisco, so the same above should apply.

my $t = Net::SSH2::Cisco->new( [...] prompt => '/(?m:^ [...] s*$)/'; # or whatever matches your prompt );

Also agree with zentara; waitfor_clear shouldn't need to be messed with, but if you're going to, at least us integer 0 (not '0' string).

Replies are listed 'Best First'.
Re^2: Net::SSH2::Cisco and Nexus switches
by cnoyes72 (Initiate) on Aug 15, 2018 at 20:16 UTC

    Thanks for the response. It looks like the nexus prompt adds a space after the "#" character. However, now the script appears to be prepending a "Z" before the command. I haven't changed anything in the script beside the prompt match, this makes no sense.

      In waitfor(), if there is a timeout and waitfor_clear() is set, an ios_break('Z') (ctrl-z) is sent. That explains the Z. If you're confident you have the prompt correct, try experimenting with waitfor_clear().

        Thanks again for the response.

        It looks like the prompt match still isn't working. There is something about the NX-OS prompt/response that the underlying net::telnet::cisco module doesn't like. It works great with IOS and IOS-XE. I did find that Control::CLI works great with NX-OS but doesn't work with IOS or IOS-XE (it behaves like nx-os did with net::ssh2::cisco). It could be that the NX-OS cli behaves just like a linux session; not surprising considering nx-os is layered upon linux. So I guess I'll have to use both modules in my backup script (that script works great with Net::Telnet today but we are trying to shutdown Telnet on the switches).

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://1220345]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others chilling in the Monastery: (6)
As of 2020-05-29 10:58 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    If programming languages were movie genres, Perl would be:















    Results (169 votes). Check out past polls.

    Notices?