By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
434,917 Members | 1,305 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 434,917 IT Pros & Developers. It's quick & easy.

Telnet Clear Screen?

P: n/a
Hi.

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

Thanks!
Jan 18 '08 #1
Share this Question
Share on Google+
9 Replies


P: n/a
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.
--
Ignacio Machin
http://www.laceupsolutions.com
Mobile & warehouse Solutions.
"pbd22" <du*****@gmail.comwrote in message
news:c7**********************************@s13g2000 prd.googlegroups.com...
Hi.

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

Thanks!

Jan 18 '08 #2

P: n/a
On Jan 18, 2:04*pm, pbd22 <dush...@gmail.comwrote:
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.
Jan 18 '08 #3

P: n/a
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!

Jan 18 '08 #4

P: n/a
On Fri, 18 Jan 2008 13:27:41 -0800, pbd22 <du*****@gmail.comwrote:
[...]
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
Jan 18 '08 #5

P: n/a
pbd22 wrote:
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".

<ESCis a single char. And it is uppercase J.

Arne
Jan 19 '08 #6

P: n/a
But one little thing "<ESC>[2j" will not work - instead use
"\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..
Jan 20 '08 #7

P: n/a
On Jan 18, 8:42 pm, Arne Vajhøj <a...@vajhoej.dkwrote:
pbd22 wrote:
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".

<ESCis 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
Jan 21 '08 #8

P: n/a
pbd22 wrote:
On Jan 18, 8:42 pm, Arne Vajhøj <a...@vajhoej.dkwrote:
>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".

<ESCis 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
Jan 21 '08 #9

P: n/a
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
It grows, its going to kill us all... run... the space is coming..
THE SPACE stole chr$(12)
Jan 26 '08 #10

This discussion thread is closed

Replies have been disabled for this discussion.