Beefy Boxes and Bandwidth Generously Provided by pair Networks
good chemistry is complicated,
and a little bit messy -LW
 
PerlMonks  

Re: Need help with a grep script

by kschwab (Priest)
on Nov 08, 2013 at 14:39 UTC ( #1061718=note: print w/ replies, xml ) Need Help??


in reply to Need help with a grep script

I'll help since this may push you back in the direction of using ssh instead of slinging router passwords around in cleartext :)

use Net::OpenSSH; use Net::Telnet; my $promptre = '/\w+[\$\%\#\>]\s{0,1}$/o'; my $ssh = Net::OpenSSH->new('hostname', user => 'username', password => 'password', kill_ssh_on_timeout => 1, timeout => 30); my ($fh, $pid) = $ssh->open2pty({stderr_to_stdout => 1}); my $cn = Net::Telnet->new( fhopen => $fh, prompt => $promptre, timeout => 30, errmode => 'return', telnetmode => 0, cmd_remove_mode => 1, output_record_separator => "\r", ); my @memory = $cn->cmd("show memory"); my @process = $cn->cmd("show process");


Comment on Re: Need help with a grep script
Download Code
Replies are listed 'Best First'.
Re^2: Need help with a grep script
by FloydATC (Chaplain) on Nov 08, 2013 at 16:26 UTC

    Using SSH is better than Telnet unless the assignment specifically says to use Telnet :-)

    -- FloydATC

    Time flies when you don't know what you're doing

      Uh, okay...from the OP:
      PROCEDURE
      
       Step 1: Login to the node using SSH or Telnet.
      

Log In?
Username:
Password:

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

How do I use this? | Other CB clients
Other Users?
Others having an uproarious good time at the Monastery: (15)
As of 2015-07-31 09:26 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    The top three priorities of my open tasks are (in descending order of likelihood to be worked on) ...









    Results (276 votes), past polls