How to read terminal reports from a C program, Help !

Francis Demierre francis at hslrswi.UUCP
Thu Mar 1 08:48:47 AEST 1990


Hi Netland !

I was trying today to write a routine that would query the status of a printer
connected to a vt320 terminal.

To get a printer status report, an escape sequence is to be sent to the terminal
( ^[[?12n as far as I remember). The terminal will then generate a reply 
escape sequence such as ^[[?10n (Printer not connected).

My question is:

Under UNIX from a C program, how do you read the reply from the terminal ?
(as far as I could experiment, the reply comes back on stdin...)

Let's say I send the query with somwething like 'puts("\033[?12n");', how
do I read the answer of the terminal. I would also like to use a similar
method to read the terminal setting (VT100, VT220 or VT320 mode) and
the function keys content. What is the magic ?

Thank you in anticipation !
(answers preferably by Email as this is probably a "green horns" question ;-) )

BTW: I need a portable code that would run on RT AIX, PS2 AIX, XENIX and
     ULTRIX if it is possible.

-------------------------------------------------------------------------------
Francis Demierre       UUCP: ...!mcvax!cernvax!hslrswi!francis
                       Unix mail: francis at hslrswi.UUCP
-------------------------------------------------------------------------------



More information about the Comp.std.c mailing list