Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations IamaSherpa on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Net::Telnet question?

Status
Not open for further replies.

devilpanther

Programmer
Oct 8, 2004
57
IL
I'm trying to use the Net::Telnet but I have a small problem.

I connect the server and send a command.
The server receives the command and sends me the output.
The thing is, because the output is not complete but has a: --MORE-- at the bottom is makes the
@lines = $telnet->cmd("show port physical 5/3"); to timeout...
(using a packet sniffer I can see that the server sends data back to the client)

How can I avoid this kind of problem?
Code:
#!/usr/bin/perl

use Net::Telnet;

$telnet = Net::Telnet->new(Prompt => '', Timeout => 10) or die "unable to init";

$telnet->open("192.169.1.1") or die "unable to connect server";
$telnet->login("username", "password") or die "unable to login";
[b][COLOR=red]@lines = $telnet->cmd("show port physical 5/3");[/color]
[COLOR=green]# this line never returns[/color][COLOR=green]a value but simply timeouts[/color][/b]
print @lines;

Thank you.
 
Have you tried adding a linefeed to the command?
e.g.
Code:
@lines = $telnet->cmd("show port physical 5/3\n");



Trojan.
 
I don't really see how that helps... the cmd already does it by itself, no?

Is it possible that the Prompt => '' needed to be adjusted? to detect --MORE-- ?
 
Can you please explain to me how the Prompt=>'' works? what am I matching?
 
It's been a long time since I've used Net::Telnet so I'll leave it to someone with more current experience to answer your question.
Good luck.


Trojan.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top