Telnet
RouterOS general discussion

12 posts   •   Page 1 of 1
SA
just joined
 
Posts: 21
Joined: Wed Jul 28, 2004 12:03 am

Telnet

by SA » Fri Aug 29, 2008 2:18 pm

After upgrading to 3.13 from 3.10 my Net::Telnet perl scripts don't work anymore.
Seems like telnet server was changed, but I can't find anything about it in the changelog.
2.9 also works fine.
The ploblem is apparently with terminal type handling, 2.9 says "terminal type is network", 3.13 just hangs after the MikroTik banner.

User avatar
sergejs
MikroTik Support
MikroTik Support
 
Posts: 6262
Joined: Thu Mar 31, 2005 3:33 pm
Location: Riga, Latvia

Re: Telnet

by sergejs » Fri Aug 29, 2008 4:18 pm

Scripting/console is changed between 2.9 and 3.0, but there should not be too much difference between 3.10 and 3.13 console functions.

User avatar
vegard
newbie
 
Posts: 25
Joined: Sat Feb 12, 2005 7:55 pm

Re: Telnet

by vegard » Fri Aug 29, 2008 6:21 pm

We've also seen this with 3.x. Try hitting enter (send "\r\n") a few times. It also happens with mac telnet.

SA
just joined
 
Posts: 21
Joined: Wed Jul 28, 2004 12:03 am

Re: Telnet

by SA » Sun Aug 31, 2008 10:14 pm

There is nothing to "hit", the problem is with perl scripts (which worked fine with 2.9 and even with older 3.x versions).
Yes, there should not be too much difference, but seems like there is :(

Once again, the script does not receive command prompt, MT telnet server just hangs after login banner.

User avatar
janisk
MikroTik Support
MikroTik Support
 
Posts: 5925
Joined: Tue Feb 14, 2006 10:46 am
Location: Riga, Latvia

Re: Telnet

by janisk » Mon Sep 01, 2008 1:15 pm

try to provide login parameters in you scripts.

SA
just joined
 
Posts: 21
Joined: Wed Jul 28, 2004 12:03 am

Re: Telnet

by SA » Tue Sep 02, 2008 10:07 am

Seems like nobody really reads my message :(
The script that works with 2.9 and 3.10 does NOT work with 3.13 due to some change in the console code.
It hangs after login (there is a "logged in via telnet" message in the /log).

User avatar
normis
MikroTik Support
MikroTik Support
 
Posts: 19335
Joined: Fri May 28, 2004 11:04 am
Location: Riga, Latvia

Re: Telnet

by normis » Tue Sep 02, 2008 1:04 pm

Please paste the entire script here, or send it to support, so we can check what is wrong with ROS 3.13
No answer to your question? How to write posts

SA
just joined
 
Posts: 21
Joined: Wed Jul 28, 2004 12:03 am

Re: Telnet

by SA » Wed Sep 03, 2008 11:52 am

Code: Select all
#!/usr/bin/perl

use strict;
use Net::Telnet;

unless (@ARGV > 2) { exit 2; }

my $nasip = shift(@ARGV);
my $community = shift(@ARGV);
my $login = shift(@ARGV);

my ($user,$pass,$t);
($user,$pass)=split(/:/,$community,2);

$t = new Net::Telnet (Timeout => 5,
                      Errmode => "return",
#                     Dump_Log => '/tmp/telnet.log',
                     Prompt => '/> $/');
if ($t->errmsg){
    exit 24;
}
$t->open($nasip);
if ($t->errmsg){
    exit 24;
}
$t->login($user, $pass);
if ($t->errmsg){
    exit 24; #returns here with timeout in 3.13
}
$t->cmd("/interface pppoe-server");
$t->cmd("remove [find user=\"$login\"]");
$t->cmd("/quit");
$t->close();
exit 0;


Here it is. The script is used to disconnect pppoe users
usage: disconnect.pl <mt ip> <mt username>:<mt password> <pppoe username>

SA
just joined
 
Posts: 21
Joined: Wed Jul 28, 2004 12:03 am

Re: Telnet

by SA » Tue Sep 23, 2008 11:01 am

Doesn't work in 3.14 either

User avatar
mrz
MikroTik Support
MikroTik Support
 
Posts: 4090
Joined: Wed Feb 07, 2007 1:45 pm
Location: Latvia

Re: Telnet

by mrz » Tue Sep 23, 2008 11:18 am

janisk wrote:try to provide login parameters in you scripts.

Have you tried it?

None of these scripts will work unless console colors and terminal detection is disabled

User avatar
Chupaka
Forum Guru
Forum Guru
 
Posts: 7236
Joined: Mon Jun 19, 2006 11:15 pm
Location: Home Network Ltd., Minsk, Belarus

Re: Telnet

by Chupaka » Tue Sep 23, 2008 12:04 pm

yesss, exactly =)

What's new in 3.0rc14:

*) console - added login parameters, passed as part of login name, after '+';
can be used to disable colors (+c) and terminal autodetection (+t), e.g.
"admin+ct";
For every complex problem, there is a solution that is simple, neat, and wrong.

¡ɹǝ|SOɹǝʇnoɹ ʞıʇoɹʞıW ɯ‚|

MikroTik. Your life. Your routing.

skype: pavel.skuratovich

SA
just joined
 
Posts: 21
Joined: Wed Jul 28, 2004 12:03 am

Re: Telnet

by SA » Thu Sep 25, 2008 3:43 pm

Yes, it works with +ct, but the script must work with both 2.9 and 3.x. (and worked before 3.13).
Anyway, this is sort of a solution, thanks :D

12 posts   •   Page 1 of 1

Who is online

Users browsing this forum: Bing [Bot], Exabot [Bot] and 38 guests

It is currently Mon Dec 22, 2014 9:58 am