Home: Perl Programming Help: Beginner:
Problems with Net::Telnet



anton_
New User

Dec 18, 2012, 9:36 AM


Views: 3187
Problems with Net::Telnet

Hi!

First of all, I'm a beginner at perl - so be easy on me :)

I'm trying to write a program which uses Net::Telnet to check information on my router (switch), and I have a problem with some commands returning a lot of data.

I'm using:

Code
my @tmp = $telnet->cmd("sh ver");

It causes a time-out and quits the program.

My theory is that the output data is page'd (the switch responds with either "--More--" or "Press c for continous, q for quit, <space> for one more row" and then halts until a char has been pressed. But "->cmd" doesn't issue this, tries to read for X seconds then quits.

Is there any way I can tell the Telnet-package to read everything, or do I need to use $telnet->send and $telnet->getline? :<

I know that this might be the wrong forum to ask this, but I'm running out of ideas. =)

Thanks in advance.

Best regards,
Anton.


rovf
Veteran

Dec 20, 2012, 1:44 AM


Views: 3159
Re: [anton_] Problems with Net::Telnet

Of course, paging *might* be the problem, but in general, the problem is likely that whatever the command sends back, does not match the prompt pattern Net::Telnet expects at this time.

I suggest to use dump_log() to see what was sent back.


Perlhack
New User

Jan 2, 2013, 9:49 AM


Views: 3061
Re: [anton_] Problems with Net::Telnet

This command generates a lot of output from a cisco device so paging might be the problem. Execute command "term length 0" to turn off paging.

Can you share the script and the output that is returned?


anton_
New User

Jan 2, 2013, 1:25 PM


Views: 3048
Re: [Perlhack] Problems with Net::Telnet

Hi!

Sorry for the late answer.
The hardware is running other than cisco, so "term length 0" doesn't work.

However, I've rewritten everything and used basic socket I/O, so it works now. :)

Cheers,
Anton