Reading raw input from /dev/tty using shell
Jimmy Aitken
jimmy at pyrps5
Thu Mar 30 05:17:17 AEST 1989
In article <52 at crdgw1.crd.ge.com> barnett at crdgw1.crd.ge.com (Bruce Barnett) writes:
>Does anyone know a clever method of reading raw data from /dev/tty
>using a shell script and standard Unix tools?
This is the method that I shell script that I use to chnage attributes
of a sun window. The main program has lots of options and needs to
know the current position of the window read via escape sequences.
Note that you musn't type anything whilst it's trying to read the
input as it would get messed up with the stuff that the sun window is
"typing". This runs fine under sunOS 3.5
The code fragment goes something like:
stty raw > /dev/tty
echo -n "escape sequencs that causes the string to be returned" > /dev/tty
ch=`dd </dev/tty count=1 2>/dev/null`
stty cooked > /dev/tty
This can be used e.g:
echo -n "${esc}[18t"
to get the size of the window
>Call me a purist, but I was wondering if I could replace a 10 line C program
>with a 5 line shell script? :-)
Or even 4 line...
More information about the Comp.unix.wizards
mailing list