Ad blocker detected: Our website is made possible by displaying online advertisements to our visitors. Please consider supporting us by disabling your ad blocker on our website.
Post general support questions here that do not specifically fall into the Linux or Windows categories.
Moderators: Developers , Moderators
dylan6000
Posts: 4 Joined: Tue May 19, 2015 12:34 am
Post
by dylan6000 » Mon Feb 01, 2016 9:27 am
HI,
I am hoping that some genius can assist me. I have a perl script that that i got from here (
http://blog.nobiscuit.com/2012/09/16/gr ... ing-cacti/ )
to log in to dsl modem and display the sync rates. If i manually telnet into the modem i can get the sync rate displayed, however when the perl script runs the output is blank. I am not very good with perl and am hoping someone here can assist.
Perl Script
Code: Select all
#!/usr/bin/perl
use Expect;
# Example sesion:
#
# $ telnet x
# Trying x...
# Connected to x.
# Escape character is '^]'.
#
# Password: **********
# Copyright (c) 2001 - 2012 TP-LINK TECHNOLOGIES CO., LTD
# TP-LINK> wan adsl c
# near-end interleaved channel bit rate: 10313 kbps
# near-end fast channel bit rate: 0 kbps
# far-end interleaved channel bit rate: 1293 kbps
# far-end fast channel bit rate: 0 kbps
# TP-LINK> exit
$timeout = 20;
$host = $ARGV[0];
$login_pass = $ARGV[1];
$prompt="TP-LINK>";
$command="wan adsl c";
my $exp = Expect->spawn("telnet $host")
or die "Cannot spawn $command: $!\n";
$exp->log_user(0);
$exp->expect($timeout, "Password:");
$exp->send("$login_pass\r");
$exp->expect($timeout, $prompt);
$exp->send("$command\r");
$exp->expect($timeout, $prompt);
$out = $exp->before();
@rates;
$x = 0;
while ($out =~ /(\d+)/g) {
$rates[$x] = $1;
$x++;
}
print "dir:$rates[0] dfr:$rates[1] uir:$rates[2] ufr:$rates[3]\n";
$exp->send("exit\r");
$exp->soft_close();
The result that displays on screen is
dir: dfr: uir: ufr:
Any assistance would be greatly appreciated.
phalek
Developer
Posts: 2838 Joined: Thu Jan 31, 2008 6:39 am
Location: Kressbronn, Germany
Contact:
Post
by phalek » Mon Feb 01, 2016 10:02 am
Is this the same process/prompt/text for your device:
Code: Select all
# Example sesion:
#
# $ telnet x
# Trying x...
# Connected to x.
# Escape character is '^]'.
#
# Password: **********
# Copyright (c) 2001 - 2012 TP-LINK TECHNOLOGIES CO., LTD
# TP-LINK> wan adsl c
# near-end interleaved channel bit rate: 10313 kbps
# near-end fast channel bit rate: 0 kbps
# far-end interleaved channel bit rate: 1293 kbps
# far-end fast channel bit rate: 0 kbps
# TP-LINK> exit
If not, then please provide an example for your device
dylan6000
Posts: 4 Joined: Tue May 19, 2015 12:34 am
Post
by dylan6000 » Mon Feb 01, 2016 10:13 am
Hi,
Prompt looks the same. See below for my exact process, in case you see something I don't.
Code: Select all
dylanc@monitoring:~$ telnet 192.168.1.1
Trying 192.168.1.1...
Connected to 192.168.1.1.
Escape character is '^]'.
Password: *****
Copyright (c) 2001 - 2014 TP-LINK TECHNOLOGIES CO., LTD.
TP-LINK> wan adsl c
near-end interleaved channel bit rate: 10239 kbps
near-end fast channel bit rate: 0 kbps
far-end interleaved channel bit rate: 1022 kbps
far-end fast channel bit rate: 0 kbps
TP-LINK> exit
Connection closed by foreign host.
dylanc@monitoring:~$
Hope this helps.
Users browsing this forum: No registered users and 3 guests