My plan is to offer a route-server, which is a small interactive program, via telnet to the world. Like this: telnet://route-server.he.net

As a minimal example, I'd start with a simple bash, offered via socat:

socat TCP-LISTEN:9001,reuseaddr,crnl,fork EXEC:bash,pty,stderr,sane,setsid,sigint,echo=0

Now I connect using telnet:

$ telnet localhost 9001

And it seems to work at first:

$ echo foo

The problem is: some special characters like ESC, arrow keys, etc. are printed as their shell escape codes. Example for 'arrow up':

$ ^[[A

Also, clicking/scrolling/... prints escape codes, too:

$ ^[[M r>^[[M#r>

The question is: how can I fix this behaviour in a way that clients can continue using telnet without any client side options or hacks, as it does on existing route-servers out there.

migrated from serverfault.com Sep 2 '16 at 15:57

This question came from our site for system and network administrators.

  • Use in.telnetd, which already offers interactive shell. Don't reinvent the wheel. – Ipor Sircer Aug 30 '16 at 17:00

Based on ipors comment we managed to run the service with following setup:

xinetd runs telnetd from GNU Inetutils (ftp://ftp.gnu.org/gnu/inetutils/)

server = /path/to/custom/telnetd

In the server_args, we defined an exec-String which points to a wrapper-script to run our birdc with the required options

server_args = -h -E "/opt/bird-telnet.sh"

/opt/bird-telnet.sh looks like

/usr/sbin/birdc -r -s /var/run/bird/bird.ctl

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.