Reading from stdin without RETURN and echo

Reading from stdin without RETURN and echo

Post by Rui Cast » Tue, 23 Oct 2001 19:33:43



Hi,

I'm programming in C on a Red Hat 6.2 system and I'd like to know how
can I read a single character from the keyboard without waiting for
the RETURN key? I'd also like to know how can I stop characters from
being echoed to the stdout when they're typed?

Thanks for the answer,
Rui

 
 
 

Reading from stdin without RETURN and echo

Post by Josef M?ller » Tue, 23 Oct 2001 21:12:54



> Hi,

> I'm programming in C on a Red Hat 6.2 system and I'd like to know how
> can I read a single character from the keyboard without waiting for
> the RETURN key? I'd also like to know how can I stop characters from
> being echoed to the stdout when they're typed?

man tcgetattr/tcsetattr

--
Josef M?llers (Pinguinpfleger bei FSC)
        If failure had no penalty success would not be a prize
                                                -- T.  Pratchett

 
 
 

Reading from stdin without RETURN and echo

Post by Morris Dove » Tue, 23 Oct 2001 22:40:16



> I'm programming in C on a Red Hat 6.2 system and I'd like to know how
> can I read a single character from the keyboard without waiting for
> the RETURN key? I'd also like to know how can I stop characters from
> being echoed to the stdout when they're typed?

Rui...

Consider buying W. Richard Stevens' "Advanced Programming in the UNIX
Environment".

Download http://www.iedu.com/mrd/c/getch.c
--
Morris Dovey
West Des Moines, Iowa USA

 
 
 

1. Read stdin, no echo

Yes, you must tell your terminal not to echo characters.

stty -help
[...]
  [-]echo       echo input characters
[...]

Then, you can inclose your reading command between a "stty -echo" and a "stty
echo" as in :

stty -echo ; read var ; stty echo

or

stty -echo ; cat > file ; stty echo

The same can be done with other shells.

--
Stephane

2. Linux on X-Box

3. Piping - from a file then return to reading from stdin

4. Can't find some manpages.

5. HELP: Reading from stdin without waiting ... how?

6. jsh

7. How to read chars from stdin without having to press <enter>

8. Couldn't boot up the IBM Network Station (8363-Exx)

9. Read from stdin without waiting

10. reading without echoing to the screen

11. Reading Input without echoing chars

12. reading without echoing to the screen

13. Read without echo'ing