Server Fault is a question and answer site for system and network administrators. It's 100% free, no registration required.

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I've written a script called by tcpserver that heavily utilizes tput and similar commands. These commands need to know how to correctly write to the terminal and rely on the TERM variable to obtain this information. Right now the TERM variable is being inherited from the console tcpserver is launched from and I would like to change this.

My clients are telnet-based terminal programs like netcat and telnet. How can I get these programs to communicate the user's terminal type to the remote server?

share|improve this question
It's a real question, but it's an obscure topic and not one that many will be able to really understand as worded. It'd probably be fine with an edit, so long as you aren't over-emphasizing how to implement this at the tcpserver level. – Andrew B Apr 11 '13 at 2:58
#Andrew Thanks. I also understood that this is a question more for a StackOverflow (or maybe even SuperUser) becouse the idea was to how to implement rfc 1091 using bash that is server through TcpServer. – LoCoZeNoz ZUE Apr 11 '13 at 10:03
Correct. On the other hand, "how do I get netcat and similar programs to report their terminal type to the remote server" is a legit question for here, so that's what I focused on. :) – Andrew B Apr 11 '13 at 15:04
I've edited the question to be appropriate for ServerFault. – Andrew B Apr 11 '13 at 15:16
@AndrewB Thanks. – LoCoZeNoz ZUE Apr 14 '13 at 18:15
up vote 2 down vote accepted

What you are looking for is something known as "terminal-type negotiation", often abbreviated to "termtype". This allows telnet-aware client software to negotiate a terminal type out of band using telnet escapes.

For the client half, telnet will automatically attempt to negotiate the terminal type. netcat on the other hand does not assume the remote server understands telnet escapes by default, and you'll need to run it with the -t option to enable telnet negotiation.

For the server half, I believe that would be up to you to implement and falls outside the scope of ServerFault's subject matter. Reading RFC1091 would be a good start.

share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

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