Switches, Hubs, and Modems
cancel
Showing results for 
Search instead for 
Did you mean: 

using perl Net::Telnet module with HP procurve

MENDES
Occasional Visitor

using perl Net::Telnet module with HP procurve

hello,

i'm trying to use the Net::Telnet module to query procurve 2524 switch, but it seems that no data are sent to the switch and i've no output data back from sent commands. does anybody success to query procurve switch ? if so can you send me an example of telnets session and how to take back results of commands ?

thank you.

my try :

#!/usr/bin/perl
use Net::Telnet;

my $session = new Net::Telnet ( Timeout=>5, Telnetmode=>0);
my $output = $session->open('192.168.1.10');
print $output;
$session->waitfor('/password $/i');
$output = $session->print('xxxxxxxxx');
print $output;
$output = $session->print('terminal length 1000');
print $output;
$output = $session->print('show version');
print $output;


$ perl hp.pl
pattern match timed-out at hp.pl line 8

3 REPLIES
Jeff Brownell
Valued Contributor

Re: using perl Net::Telnet module with HP procurve

I have not used perl to gather this data. I have been able to get 'expect' to work. Is this an option for you?
Arnaud_9
Valued Contributor

Re: using perl Net::Telnet module with HP procurve

Hi,

* On line 8, $session->waitfor('/password $/i'), "password $" mean the script wait
for "password" + SPACE + RETURN. I'm sure there is a ":" in the HP prompt.
You can try a string like "/password/i" or "/password.*$/" or "/password :/i".

* You should use a "waitfor" for the prompt after a print :
--> $session->waitfor(String => '#');

Some other tips :
- For debuging telnet scripts, a sniffer is very usefull (like ethereal).
- You should handle open failed sessions.
- To disable page mode you could use 'terminal length 0'.

Bye,
MENDES
Occasional Visitor

Re: using perl Net::Telnet module with HP procurve

i use Netcat