Telnet. How to work with simple terminal?

We want to use telnet connection to mikrotik to run scripts and read some variables.

By default, MT use ansi terminal and sends some escape-characters to control cursor position.

we use simple telnet client in Java and we have some problems with it - it haven’t cursor and all escape-characters accepted as data.
We try to filter it but there is some bugs like
[ u s e r @ M i k r o T i k ] > [ u s e r @ M i k r o T i k ] >
at start session because MT sends escape-character which sets cursor on first position..

Do MT support simple terminal mode without non-text characters? (like cisco, dlink, telnetd, etc)

and how to switch to it?

try use ‘username+ct’ instead of ‘username’

i used +ct login but it not solves problem fully. (only disable colors)

so presents double promt at start and some additional escape-characters in even promt.

:put $Variable command reply (by sniffer):
\r\000
false\r\n
\r\000
\r\000
\r\000
\033[9999B[rionet@MikroTik] >

That is how telnet works.
http://www.faqs.org/rfcs/rfc854.html

omg, telnet is a transport layer for the terminal data!

it will send any character (include 0) to another side except 255 (it is start of telnet commands).

i am ask about supporting simple terminal which not use escape-characters!

You can switch to binary mode.

how i can switch terminal to binary mode?

2 Chupaka:
the story of problem in ru language - http://www.bgbilling.ru/forum/viewtopic.php?t=2196&postdays=0&postorder=asc&start=45&sid=115281197cdd500578471112f2c5be65

Binary mode not solve problem:

server:
IAC DO 24 IAC DO 32 IAC DO 35 IAC DO 39
client:
IAC WONT 24 IAC WONT 32 IAC WONT 35 IAC WONT 39 IAC DO 0   (try to enable binary mode)
server:
IAC WILL 0 IAC WILL 3 IAC DO 1 IAC DO 31 IAC WILL 5 IAC DO 33   (server accept binary mode)
client:
IAC DONT 3 IAC WONT 1 IAC WONT 31 IAC DONT 5 IAC WONT 33
server:
IAC WILL 3 IAC WILL 1

M i k r o T i k v 3 . 2 3

L o g i n :

client:
IAC DONT 3 IAC DONT 1 <login>

server:
P a s s w o r d :

<next we can see terminal data with escape-characters>

try to set terminal type (option 24):

server:
IAC DO 24 IAC DO 32 IAC DO 35 IAC DO 39
client:
IAC WILL 24 IAC WONT 32 IAC WONT 35 IAC WONT 39 IAC DO 0
server:
IAC WILL 0 IAC SB 24 IAC SE
client:
SB 24 IS dumb IAC SE
server:
IAC WILL 3 IAC DO 1 IAC DO 31 IAC WILL 5 IAC DO 33
client:
IAC DONT 3 IAC WONT 1 IAC WONT 31 IAC DONT 5 IAC WONT 33
server:
IAC WILL 3 IAC WILL 1

M i k r o T i k v 3 . 2 3

L o g i n :
client:
IAC DONT 3 IAC DONT 1 <login>

server:
P a s s w o r d : 

<next we can see terminal data with escape-characters>

Server accepts options but always send text with escape-characters.
Over SSH connection we can see same data, so
It is not problem of protocol - it is problem of terminal.

run standart Windows ‘telnet’ to the RouterOS. if it displays normally - it’s not a problem of terminal, it’s problem of your Telnet implementation…

p.s. have never experienced any difficulties while working with RouterOS via terminal. anyway, API rulezzz ))

standart windows telnet client keeps in memory all session data and can set cursor at any position at any time.
it is not good way to store all session data in simple telnet clients (like Java) and all vendors like cisco, dlink, etc (and telnetd too) supports simple terminal which use only plain text and client can read and use only last repy (and not needed to store full session data in memory and emulate cursor).

i wrote it 3 times, why ur not understand idea?

This telnet implementation works without problems with all equipment and only MT wants to write prompt twice - first write it, next set cursor to first position of line and write promt again. Why? So it is needed to write unique algorithms to find last command promt especially for MT..

there no answers from developers.
so i think that MT is not support simple terminal type.

developers do not visit that forum =) it’s Community Forum

and why not simply use API?

options admin+cte will disable colors, terminal detection and enable dumb mode. However carriage returns will still be used.

As Chupaka tried to say several times - API rulezzz.

mrz, thx )

billing have a standart tools to control NAS and gateways over telnet and ssh.
and there is no need to know on which hardware NAS or gateway works - cisco, dlink, or pc with freebsd or MT.
it have some high-level features like active-users monitoring over this protocol.

using api making billing dependent of used NAS and gateways. (or need add support for all api’s)

it was a problems when used MT in this system because it sends escape-characters.

so only way is try to use filter.

mrz, can you post all supported login suffixes like +ct or +cte with description?

http://wiki.mikrotik.com/wiki/Console_login_process#Console_login_options