Beefy Boxes and Bandwidth Generously Provided by pair Networks
XP is just a number

Re^4: Using Net::SSH2 with Net::Telnet::Cisco

by gnork (Scribe)
on Aug 07, 2012 at 11:02 UTC ( #985938=note: print w/replies, xml ) Need Help??

in reply to Re^3: Using Net::SSH2 with Net::Telnet::Cisco
in thread Using Net::SSH2 with Net::Telnet::Cisco

Another late reply:

I had to make a few adjustments to your code to get it to work properly on a Cisco device:

use strict; use warnings; use Net::OpenSSH; use Net::Telnet; $Net::OpenSSH::debug = -1; my $promptEnd = '/\w+[\$\%\#\>]\s{0,1}$/o'; my $timeout = 60; my $ssh = Net::OpenSSH->new('', user => 'johndoe', password => 'secretpass', kill_ssh_on_timeout => 1, timeout => $timeout); # stderr_to_stdout was required to get Net::Telnets waitfor() to work my ($fh, $pid) = $ssh->open2pty({stderr_to_stdout => 1}); my %params = ( fhopen => $fh, prompt => $promptEnd, timeout => $timeout, errmode => 'return', telnetmode => 0, cmd_remove_mode => 1, output_record_separator => "\r", ); my $conn = Net::Telnet->new( %params ); my @lines = $conn->cmd("show tech"); print @lines;

PS: Error checks removed, insert them at will.

cat /dev/world | perl -e "(/(^.*? \?) 42\!/) && (print $1))"

Log In?

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://985938]
[vickycanada]: Hi, Can anyone please help me with this - 1203954
[vickycanada]: #1203954

How do I use this? | Other CB clients
Other Users?
Others chanting in the Monastery: (4)
As of 2017-11-21 21:48 GMT
Find Nodes?
    Voting Booth?
    In order to be able to say "I know Perl", you must have:

    Results (312 votes). Check out past polls.