Telnet Clear Screen?

  • Thread starter Thread starter pbd22
  • Start date Start date
P

pbd22

Hi.

Does anybody know how to issue a clear screen command like DOS "cls"
in a telnet session?

Thanks!
 
Hi,

IIRC it does depend of what terminal is being emulated. Some terminals do
not allow it.
Of course you can always emit X (20?) empty rows and that will clean it.
 
Hi.

Does anybody know how to issue a clear screen command like DOS "cls"
in a telnet session?

Thanks!

Like Ignacio says, it depends on the terminal being emulated. For the
old DEC VT style terminals, there is an "escape sequence" that when
sent to the terminal would clear the screen, <ESC>[2J.
 
Like Ignacio says, it depends on the terminal being emulated. For the
old DEC VT style terminals, there is an "escape sequence" that when
sent to the terminal would clear the screen, <ESC>[2J.


Thanks guys.

Well, I have written a telnet server in C# that captures the port 23
connection and uses TcpClient to read/write to interact with the
user's DOS console.

So, I am a little confused. Should I be sending these commands
as such:

buffer = ASCII.GetBytes("<ESC>[2j");
_clientStream.Write(buffer, 0, buffer.Length);
_clientStream.Flush();

Well, I will give it a shot (correct me if I am wrong).

Thanks!
 
[...]
So, I am a little confused. Should I be sending these commands
as such:

buffer = ASCII.GetBytes("<ESC>[2j");
_clientStream.Write(buffer, 0, buffer.Length);
_clientStream.Flush();

That will only work if the other end has a terminal emulator that is
acting as a VT-series terminal (or at least as some terminal that uses the
same control codes). In other words, it might work but it's not something
you can count on.

You seem to be confusing the user terminal with telnet. Telnet is not
terminal emulation, and doesn't really have anything to do with terminal
emulation. You may want to layer some additional protocol above the
telnet protocol, to support things like character formatting and screen
clearing, but you should not expect the remote end to support those
things. A telnet client can be fully functional without having _any_ sort
of graphical control over the display.

Which is not to say that the telnet protocol doesn't support escape
codes. It does, and your server should be aware of these and handle them
properly. See the actual telnet specification for details:
http://www.faqs.org/rfcs/rfc854.html

Unless your server fully conforms to the specification, you don't actually
have a telnet server.

Pete
 
pbd22 said:
Well, I have written a telnet server in C# that captures the port 23
connection and uses TcpClient to read/write to interact with the
user's DOS console.

So, I am a little confused. Should I be sending these commands
as such:

buffer = ASCII.GetBytes("<ESC>[2j");
_clientStream.Write(buffer, 0, buffer.Length);
_clientStream.Flush();

Well, I will give it a shot (correct me if I am wrong).

Whether the concept will work or not in your context I dont't know.

It should work if the C# program is running on the remote system
and outputs to a terminal emulator emulating VT200 or higher.

Like running the app with mono on a Linux box.

But one little thing "<ESC>[2j" will not work - instead use
"\u001B[2J".

<ESC> is a single char. And it is uppercase J.

Arne
 
But one little thing said:
"\u001B[2J".

Jepp, esc =ascii 27 and that (<ESC>) might not work ;)
if you dont know what terminal is connected.. 50 lines of CR/LF or
just LF?
google for ANSI-BBS terminal would be a sugestion...
as I alway said "Who stole chr$(12)" of FF as someone called it... try
that..
 
pbd22 said:
Well, I have written a telnet server in C# that captures the port 23
connection and uses TcpClient to read/write to interact with the
user's DOS console.
So, I am a little confused. Should I be sending these commands
as such:
buffer = ASCII.GetBytes("<ESC>[2j");
_clientStream.Write(buffer, 0, buffer.Length);
_clientStream.Flush();
Well, I will give it a shot (correct me if I am wrong).

Whether the concept will work or not in your context I dont't know.

It should work if the C# program is running on the remote system
and outputs to a terminal emulator emulating VT200 or higher.

Like running the app with mono on a Linux box.

But one little thing "<ESC>[2j" will not work - instead use
"\u001B[2J".

<ESC> is a single char. And it is uppercase J.

Arne

Thanks all.

Arne - that worked, sort of.
It cleared the screen (thanks) but each time a function clears the
screen the space
at the top gets bigger. It seems that something that I can't see is
getting
written and gets built upon the next time the clear statement fires.

Also, what exactly is the \u? Is there a way that I can find out what
other commands
I have at my disposal in the same format as the one you just provided
(ie. \u plus
something).

Thanks again!
Peter
 
pbd22 said:
It should work if the C# program is running on the remote system
and outputs to a terminal emulator emulating VT200 or higher.

Like running the app with mono on a Linux box.

But one little thing "<ESC>[2j" will not work - instead use
"\u001B[2J".

<ESC> is a single char. And it is uppercase J.
It cleared the screen (thanks) but each time a function clears the
screen the space
at the top gets bigger. It seems that something that I can't see is
getting
written and gets built upon the next time the clear statement fires.

Very difficult to troubleshoot. What terminal emulator ? What terminal
does it emulate ? What space is getting bigger ?
Also, what exactly is the \u? Is there a way that I can find out what
other commands
I have at my disposal in the same format as the one you just provided
(ie. \u plus
something).

\u001B means the unicode character 27 (1B in hex is 27 in decimal).

If the terminal is ANSI or VT100 or VT200 compatible there
are a bunch of socalled escape sequences you can use.

Try google for "VT100 escape sequence" or "VT200 escape sequence" - you
will get plenty of hits.

Arne
 
It cleared the screen (thanks) but each time a function clears the
It grows, its going to kill us all... run... the space is coming..
THE SPACE stole chr$(12)
 
Back
Top