query input with time-out

Custom / CUSTOM
March 25, 2010 at 02:26:56
Specs: linux red hat, 2.401 GHz / 2047 MB
In a batch script, I'm wanting to query on input of 1 character, but when no key pressed, I want the query to timeout and contiue nevertheless (similar to CHOICE on Windows).

How can that be done ?

See More: query input with time-out

Report •

March 25, 2010 at 20:17:28
my isp (ubuntu) has command "read" which has a -t timeout option as well as a character specification option. READ doesn't have a MAN entry, but i typed "help read" to find out what it has. Not sure if it will work though, haven't tested it using the timeout feature.
-edit- update - yeah, this seemed to work:
read -t 5 -n 1 testing
limits to 1 char, 5 seconds value into $testing

Report •

March 27, 2010 at 09:30:58
That worked just great ! Funny how I missed that tool all those years ... is it Linux only ?

I suspect it is, since when you do MAN READ (in Linux) he is showing a overview of a lot of linux-commands, amongst which is READ

Works great, thanks

Report •

Related Solutions

Ask Question