[Date Prev][Date Next] [Thread Prev][Thread Next]
[Thread Index]
[Date Index]
[Author Index]
Re: Keyboard input Buffer
- From: Rick Stevens <rstevens vitalstream com>
- To: Getting started with Red Hat Linux <redhat-install-list redhat com>
- Subject: Re: Keyboard input Buffer
- Date: Tue, 10 Aug 2004 13:44:53 -0700
karlp ourldsfamily com wrote:
In other languages, I can read the keyboard buffer and test for input. Is
there any command/sh function that will allow for such behavior from
within a shell script?
I'm envisioning something like:
for i in `ls /dev/tty*`
do
something or other
KEYIN=`check keyboard buffer prg`
if [ "$KEYIN" ! '' ] ; then
:
else
do something else
fi
You can't "peek" at the keyboard buffer without reading it in bash.
However, you could:
for i in `ls /dev/tty`; do
something
read -t 1 TEST
if [ "foo$TEST" = "foo" ]; then
nothing was typed in in the last second
else
something was typed in, but it's in $TEST now, not the buffer
fi
done
The value after the "-t" in the read command sets the timeout in
seconds. You'll be responsible for putting the buffer back together
if you need the data later.
----------------------------------------------------------------------
- Rick Stevens, Senior Systems Engineer rstevens vitalstream com -
- VitalStream, Inc. http://www.vitalstream.com -
- -
- Linux is like a wigwam...no windows, no gates...and apache inside! -
----------------------------------------------------------------------
[Date Prev][Date Next] [Thread Prev][Thread Next]
[Thread Index]
[Date Index]
[Author Index]