How to get characteristics of a remote terminal ?

How to get characteristics of a remote terminal ?

Post by Dragon F » Wed, 07 Jul 1993 08:45:51



Hello everybody !

My question  as always is trivial:

How can I determine the characteristics
of a remote terminal from within C program,
say, under UNIX ?   In particular I'm interested
in getting the size of the screen (number of rows
and columns). Formerly I used to determine the
terminal by sending control sequences
like e.g. "\033[c" or "\033[>c" and read the response
which worked fine for VT-series stuff, but it
didn't give size of the screen. Hmmm, curses
give the right answer only for the local terminal,
but give only default 24x80 (or 65x80) size for remote (say,
the one under telnet). On the other hand I saw several
times when some remote applications printed something
like
"reading your environment..."
meaning apparently that they were able to
determine "my environment". Is there any answer ?

Cordially,
Serge

 
 
 

How to get characteristics of a remote terminal ?

Post by Dan Po » Wed, 07 Jul 1993 20:05:30



Quote:>How can I determine the characteristics
>of a remote terminal from within C program,
>say, under UNIX ?   In particular I'm interested
>in getting the size of the screen (number of rows
>and columns).

...

Quote:>Is there any answer ?

Of course, Serega.

Use the TIOCGWINSZ function of the ioctl() system call to get the terminal
size. "man ioctl" won't probably supply too much information, but will
provide pointers to the appropriate man pages, which seem to be system
dependent.

Dan
--
Dan Pop
Tel:   +41.22.767.4534

Mail:  CERN - PPE, Bat. 20 R-054, CH-1211 Geneve 23, Switzerland

 
 
 

How to get characteristics of a remote terminal ?

Post by A. Khatt » Thu, 08 Jul 1993 00:11:25




>>How can I determine the characteristics
>>of a remote terminal from within C program,
>>say, under UNIX ?   In particular I'm interested
>>in getting the size of the screen (number of rows
>>and columns).

How about using the termcap library? Use getenv() to get the terminal type,
then read the entry from the termcap database for that terminal type using
tgetent(). You should then be able to read any terminal capability supported
by that terminal type, using tgetnum(), tgetstr() etc. Of course, this is no
use under a windowing system due to window resizing, so you would have to use
an IOCTL. (Even better, catch the SIGWINCH signal and then use ioctl() to
update how large the screen is)

Aj.
--
.-------------------------[ The Eno ]-------------------------------------.



 
 
 

1. Getting terminal characteristics from SAMSON based telnet sessions

I running a Sun SPARC 2 (SunOS 4.1.2) to which users with Macs and PCs
on their desktops telnet to for mail.  Because of the variety of kinds
of machines, there is a whole variety of screen sizes and shapes.  The
one thing evry user has in common, however, is that they all use
SAMSON for VT100 emulation.  When logging into the forsythe computer,
WYLBUR (if you've defined your term type as samson) automatically
retrieves a number of terminal characteristics from your local
machine, thus it treats a 60 line screen as a 60 line screen, and a 25
line screen as a 25 line screen, etc.  Currently, my users are having
to use the STTY command.  Since some use different machines with
different screen sizes, they can't just put the STTY command in their
.login file.

Is there a unix utility that somebody's already written that I can get
to read that info from the terminal, or barring that, does anyone know
the appropriate handshaking so that I can write it myself (i.e., what
sequence do I send down the line from the host to the PC or Mac, and
what does the SAMSON response look like)?

Any help will be greatly appreciated.

--

System Administrator
Stanford University, California

2. Q: Mounting CD-ROM under SunOS 5.5

3. Getting term characteristics into .exrc?

4. LINUX... YYEEEEEEESSSSS!!!

5. problem with ppp getting remote ip from terminal server

6. D-Link DFE-530TX card

7. Setting terminal characteristics without a login shell

8. diald won't run

9. problem with rz/sz not restoring terminal characteristics

10. Help getting remote terminal to work with a 3 wire connection with getty_ps

11. DIP gets stuck on get $remote remote

12. Remote X terminal... won't use the terminals hardware

13. Remote Terminal [cont]