Beefy Boxes and Bandwidth Generously Provided by pair Networks
The stupid question is the question not asked
 
PerlMonks  

Re: Problem with telnet and paging

by VinsWorldcom (Parson)
on Dec 19, 2012 at 13:09 UTC ( #1009563=note: print w/replies, xml ) Need Help??


in reply to Problem with telnet and paging

With your example "sh ver" command I immediately think Cisco and when I connect to Cisco routers (using Net::Telnet::Cisco by the way, which in turn uses Net::Telnet), I always issue "terminal length 0" as the first command. That disables paging and then long output like 'show ver', 'show run', etc... always work for me.

Replies are listed 'Best First'.
Re^2: Problem with telnet and paging
by anton (Initiate) on Dec 19, 2012 at 19:03 UTC
    Hi.

    Thank you all for your replies. I've looked into the solution with expect - though I don't have the package and the box I'm running the script on is very limited.

    The software is indeed Cisco, but my other switches/routes are a different kind (huawei, etc) and they do not have any support for terminal length.

    Perhaps my best option would be to use a basic i/o socket, and just read for the '--More--'-line and send a space, or whatnot?

    Thanks in advance.

      this works for me on my CISCO's... may be it's the lines...

      $telnet->prompt('/\w+# $/'); $telnet->waitfor($telnet->prompt);
      that make it work... Don't know, just figuring this out myself...
      usage: ./program.pl 10.10.10.77 z.out

      #!/usr/bin/perl use strict; use warnings; use Net::Telnet; my $uri = shift @ARGV or die "IP address needed \n Usage: ./runssh 10. +10.10.77 outputfile"; my $a = shift @ARGV or die "output file needed \n usage: ./runssh 10.1 +0.10.77 outputfile"; my $telnet = new Net::Telnet (Timeout=>15 #,Input_log => "received_data.txt" ,Input_log => $a ); $telnet->open($uri); $telnet->waitfor('/login: /i'); $telnet->print('Place_the_login_here'); $telnet->waitfor('/Password: /i'); $telnet->print('Place_the password_here'); print "Login is successful \n"; $telnet->prompt('/\w+# $/'); $telnet->waitfor($telnet->prompt); $telnet->cmd("terminal length 0"); $telnet->cmd("show interface brief"); $telnet->cmd("sh int desc"); $telnet->cmd("sh flogi data"); $telnet->cmd("sh zone act"); $telnet->waitfor($telnet->prompt); my $out = $telnet->print('exit'); print $out; $telnet->close(); my $fname = "received_data.txt"; open (my $fh, "<", $fname) or die "Can't open"; while (<$fh>) { print if /ip prefix-list/; }

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://1009563]
help
Chatterbox?
[james28909]: omg
[james28909]: im just finding out that july and august have 31 days?
[atcroft]: stevieb: Apparently it was contagious....
[atcroft]: james28909: Make both hands into fists, place them together (with thumbs concealed), and every knuckle is a month (starting with Jan.) has 31 days, every dip (between knuckles) does not....
[atcroft]: (And Feb. is the odd case, because it is 28, unless it is a year divisible by 4, or if it is divisible by both 100 and 400 (at which point it is 29).)
[james28909]: i know but scroll through your calendar on your computer.
[james28909]: i thiught you were going to say make both hands into a fist and puch yourself in the face
[atcroft]: .oO(Sorry, I probably should have said take two normal hands....)
[atcroft]: james28909: No, unless you are a politician, I wouldn't say that (and even if you are, I still probably wouldn't say that).
[james28909]: i mean how hard can it be? its just subtracting days lol

How do I use this? | Other CB clients
Other Users?
Others imbibing at the Monastery: (3)
As of 2017-04-29 04:27 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    I'm a fool:











    Results (531 votes). Check out past polls.