Sponsored Content
Top Forums Shell Programming and Scripting Using Net::Telnet in Perl to connect to an adsl modem Post 302351373 by Ravendark on Tuesday 8th of September 2009 10:23:02 AM
Old 09-08-2009
Using Net::Telnet in Perl to connect to an adsl modem

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:

Code:
$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.

Code:
[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.


Last edited by Ravendark; 09-08-2009 at 11:31 AM..
 

9 More Discussions You Might Find Interesting

1. UNIX for Dummies Questions & Answers

Got connected with Modem but cannot dial Telephone no. to connect to host

Hello There, I configure my Modem as follow. Step1. # admintool & Then from Browse --> Serial Port i select tta port and Edit --> Modify From that i select Template : Modem:Dial Out Baud Rate: 9600 Ok Step 2 # tip /dev/cua/a connected (1 Reply)
Discussion started by: abidmalik
1 Replies

2. Solaris

Solaris 10 ADSL USB modem problem

Hi, I have USB Siemens Santis 100 ADSL modem.I need driver for this modem on Solaris 10.Please help me with some info.Platform is x86.Thanks. (2 Replies)
Discussion started by: Upravnik
2 Replies

3. UNIX for Dummies Questions & Answers

cannot connect net in rhl9

I installed rhl 9 in my system but the problem is i cannot connect my net to it any help please (2 Replies)
Discussion started by: shafique
2 Replies

4. Solaris

Installing USB adsl modem?

Hello all, granted that I am an absolute beginner with Solaris, I'd like to use my adsl modem, t's a Zyxel prestige 630. I managed to install and configure it under Ubuntu using the drivers from Conexant AccessRunner ADSL USB modems with Linux ; is there a chance to do the same under Solaris 10... (0 Replies)
Discussion started by: clalfa
0 Replies

5. Windows & DOS: Issues & Discussions

Need Help on "waitfor" command in net::Telnet Module in PERL

Hi, Can anybody help me in writing command "waitfor" for string "C:\WINNT\Profiles\mfcf0508>" while using net::Telnet module. I tried the below format : $telnet->waitfor('/"C\:\WINNT\Profiles\mfcf0508>".*$/i'); Getting error as : pattern match timed-out Plz help me (3 Replies)
Discussion started by: sudhakaryadav
3 Replies

6. Shell Programming and Scripting

Need help on use of "cmd" command in net::Telnet module in PERL

in "cmd" command i want to copy the ouput of the command excuted to a particular file in a directory. How to do this..?? Ex : $telnet->cmd(String => 'allip:acl=a1;',Prompt => '/</'); i want to copy o/p of the command "allip:acl=a1;" in a log file in a particular directory. Plz suggest.. (1 Reply)
Discussion started by: sudhakaryadav
1 Replies

7. Shell Programming and Scripting

Pressing "Enter/Space bar" using Net::TELNET? in Perl

I'm trying to learn how to get my script to execute the enter button when it telnets into a router and the router displays output but you need to press the space bar or enter button to continue displaying my output of the router. How is this done? (0 Replies)
Discussion started by: xmaverick
0 Replies

8. Shell Programming and Scripting

Perl variables inside Net::Telnet::Cisco Module doesn't work

I am writing perl script to configure Cisco device but Variables inside Net::Telnet::Cisco Module doesn't work and passed to device without resolving. Please advise. here is a sample of script: use Net::Telnet::Cisco; $device = "10.14.199.1"; ($o1, $o2, $o3, $o4) = split(/\./,$device);... (5 Replies)
Discussion started by: ahmed_zaher
5 Replies

9. Shell Programming and Scripting

ENTER for modem configuration via telnet

Hiya, I'm trying to write a shell script to enter a bunch of loooooong configuration commands (to set ip, gateway etc.) for a quite outdated modem. It must be accessed via telnet. Here the preliminary code: #!/bin/bash (echo "open 192.168.1.254"; sleep 10 echo "Administrator";... (1 Reply)
Discussion started by: mrsbellamy
1 Replies
telnetd(8)						      System Manager's Manual							telnetd(8)

NAME
telnetd - The DARPA telnet protocol server SYNOPSIS
telnetd [-debug [port]] [-D modifier ...] FLAGS
Starts telnetd manually, rather than through inetd, on alternate TCP port number port (if specified). Prints out debugging information. modifiers are: Prints information about negotiation of telnet options Same as options with additional processing information Displays the data stream received by telnetd Displays data written to the pty Not yet implemented DESCRIPTION
The telnetd daemon is a server that supports the DARPA (Defense Advanced Research Projects Agency) standard telnet virtual terminal proto- col. telnetd is invoked by the Internet server (see inetd(8)) normally for requests to connect to the telnet port as indicated by the /etc/services file (see services(4)). The -debug flag may be used, to start up telnetd manually. If started up this way, port may be specified to run telnetd on an alternate TCP port number. The -D options may be used for debugging purposes. This allows telnetd to print out debugging information to the connection, allowing the user to see what telnetd is doing. The telnetd daemon operates by allocating a pseudoterminal device (see pty(7)) for a client, then creating a login process that has the slave side of the pseudoterminal as stdin, stdout, and stderr. telnetd manipulates the master side of the pseudo-terminal, implementing the telnet protocol and passing characters between the remote client and the login process. When a telnet session is started up, telnetd sends telnet options to the client side, indicating a willingness to do remote echo of charac- ters, to suppress go ahead, to do remote flow control, and to receive terminal type information, terminal speed information, and window size information from the remote client. If the remote client is willing, the remote terminal type is propagated in the environment of the created login process. The pseudoterminal allocated to the client is configured to operate in cooked mode, and with XTABS and CRMOD enabled (see tty(7)). The telnetd daemon is willing to do: echo, binary, suppress go ahead, and timing mark. telnetd is willing to have the remote client do: line mode, binary, terminal type, terminal speed, window size, toggle flow control, environment, X display location, and suppress go ahead. The telnetd daemon never sends telnet go ahead commands. Note that binary mode has no common interpretation except between similar operating systems (Unix compatible systems in this case). Note also that the terminal type name received from the remote client is converted to lowercase. The telnet command uses the default Type-of-Service value recommended by RFC1060, which is as follows: Low delay You can configure this value by specifying it in the /etc/iptos file. For more information, see iptos(4). By default, the telnetd daemon starts the login dialog using the login string specified in the message field of the /etc/gettydefs file. If you want to use a customized banner, create an /etc/issue.net or /etc/issue file. The telnetd daemon reads the file that exists and writes its contents over a new telnet connection prior to starting the login dialog. If both files exist, only the /etc/issue.net file is used. CAUTIONS
Some telnet commands are only partially implemented. Because of bugs in the original 4.2BSD telnet(1), telnetd performs some dubious protocol exchanges to try to discover if the remote client is, in fact, a 4.2BSD telnet(1). FILES
Specifies the command path. Specifies the path name for the network issue identification file. Specifies the path name for the issue identification file. RELATED INFORMATION
Commands: telnet(1). Files: iptos(4), issue(4), issue.net(4). delim off telnetd(8)
All times are GMT -4. The time now is 04:54 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy