Hello,
First of all, congratulations on this forum! Very mice material!
This is my fist thread and it has to do with connecting to an adsl modem and executing some commands.
Heres what I do:
$username = 'admin';
$passwd = 'admin';
$telnet = new Net::Telnet ( Timeout=>10, Errmode=>'return',input_log=>'input.txt', Port=> "8081" );
$telnet->open(Host => $ip_number) || print " connection refused.\n";
$telnet->waitfor("/User\ Name\ :");
$telnet->print($username);
$telnet->waitfor("/User\ Password\ :");
$telnet->print($passwd);
$telnet->waitfor("CONF\ :\>");
$telnet->print('monitor adsl history');
$telnet->waitfor("CONF\ :\>");
$telnet->print('monitor ppp');
$telnet->waitfor("CONF\ :\>");
$telnet->print('exit');
$telnet->waitfor("USER\ :\>");
$telnet->print('exit');
$telnet->waitfor("Do\ you\ want\ to\ disconnect\(y\/n\)\ \?\ \ :");
$telnet->print('y');
$telnet->close;
But it does not work. Nothing gets printed on input.txt file.
My guess is that something goes wrong with the waitfor() subs as the connection hungs-up after exiting, as I cannot connect again.
Below is a copy-paste of the output when doing it manually.
Thanks in advance!
George.
[portal@noc-5 ~]$ telnet ***.***.***.*** 8081
Trying ***.***.***.***...
Connected to ***.***.***.***.
Escape character is '^]'.
User Name : admin
User Password : *****
Telnet Manager Version 1.21.1S-O
Type ? for Command-Sensitive Help, TAB match command
CONF :> monitor adsl history
(1) ADSL Run-time Information:
<ADSL History>
Date Time Data Rate(Up/Dw) Noise Margin(U/D) Attenuation(U/D)
--------------------- ------------------ ----------------- ----------------
[09/08/2009 17:13:30] 1023/20476 Kbps 13/16 dB 0/ 3 dB
[09/08/2009 17:18:30] 1023/20476 Kbps 13/16 dB 0/ 3 dB
CONF :> monitor ppp
<PPP Session Status>
No Date Time Status Reason
-- --------------------- ------ ----------------------------------------
1 [08/01/2003 00:02:08] Up If(PPPoE1) PPP connection ok !
<PPP Failure History>
There is no failure log.
CONF :> exit
USER :> exit
Do you want to disconnect(y/n) ? : y
Disconnect by user.....Connection closed by foreign host.