[EMAIL PROTECTED]:~$ echo '#include <stdlib.h>
> #include <stdio.h>
> #include <curses.h>
>
> WINDOW *win;
>
> main(){
> int ch;
>
> win=initscr();
> noecho();
> raw();
> cbreak();
> keypad(win, TRUE);
> ch=getch();
> endwin();
> printf("%c\n", ch);
> /* printf("%d\n", ch); */
> }' > getc.c
[EMAIL PROTECTED]:~$ cc getc.c -lncurses -o getc
[EMAIL PROTECTED]:~$ a=`echo sdasd | ./getc`
en a queda:
$'\E(B\E)0\E[?1049h\E[1;24r\E[m\017\E[4l\E[?7h\E[?1h\E=\E[H\E[2J\E[24;1H\E[?1049l\r\E[?1l\E>s'
y yo s�lo quiero que reciba un caracter.
en este caso hay mucho ruido antes del caracter 's' que me interesa.
lo mismo en el caso que ingrese por teclado, aparecen muchos caracteres
que no me interesan
On Tue, 2002-03-05 at 17:29, Antonio Castro wrote:
> On Tue, 5 Mar 2002, Sistemas 1 wrote:
>
> > Alguien conoce una forma de recibir un caracter desde stdin y ponerlo en una
> > variable (sin esperar enter) en bash o ksh.
>
> Para este tipo de cosas hay que usar curses. Te d� independencia del
> tipo de terminal a trav�s de la variable de entorno TERM. curses o ncurses
> es una librer�a para C pero no hay problema te haces un programita en C y
> te lo colocas en un lugar accesible a la bash ($PATH).
>
> =============================8<-----(getchar.c)------------------------
> #include <stdlib.h>
> #include <stdio.h>
> #include <curses.h>
>
> WINDOW *win;
>
> main(){
> int ch;
>
> win=initscr();
> noecho();
> raw();
> cbreak();
> keypad(win, TRUE);
> ch=getch();
> endwin();
> printf("%c\n", ch);
> /* printf("%d\n", ch); */
> }
> =============================8<-----(getchar.c)------------------------
>
> Para compilarlo.
>
> cc getchar.c -lncurses -o getchar
>
>
> Un saludo
>
> Antonio Castro
>
> +--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+
> /\ /\ Ciberdroide Inform�tica (Tienda de Linux)
> \\W// <<< http://www.ciberdroide.com >>>
> _|0 0|_
> +-oOOO--(___o___)--OOOo----------------------------------------------------+
> | . . . . U U . . . . Antonio Castro Snurmacher [EMAIL PROTECTED] |
> | . . . . . . . . . . |
> +()()()----------()()()----------------------------------------------------+
> | *** 1.700 sitios clasificados por temas sobre Linux en ***Donde_Linux*** |
> | <<< http://www.ciberdroide.com/misc/donde/dondelinux.html >>> |
> +--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+
>
>
>
> --
> To UNSUBSCRIBE, email to [EMAIL PROTECTED]
> with a subject of "unsubscribe". Trouble? Contact [EMAIL PROTECTED]
>