timeout on read; Bourne Shell
Daniel Smith - part of the caffeine generation
daniel at island.COM
Fri May 31 02:19:55 AEST 1991
In <1153 at mwtech.UUCP> martin at mwtech.UUCP (Martin Weitzel) writes:
> In article <1991May26.165314.21533 at midway.uchicago.edu> goer at ellis.uchicago.edu (Richard L. Goerwitz) writes:
> >Is there any elegant way to achive a timeout on a read within
> >a shell script? Perhaps even "fairly elegant" would do. Even
> >a kludge?
One way is to get the grabchars package, which allows for timeouts
and default answers (and more).
A line such as:
score=`grabchars -d0 -b -n5 -t10 -r -q 'enter your score >> '`
Will set $score to 0 if return is pressed as the first character,
or if 10 seconds go by. -b means output to stdout and stderr (so that you
can see what you are typing, -t is # of seconds to time out, -n is # of
(up to) chars to get, -r means "allow return key". You can get if from
comp.sources.misc archives on uunet and elsewhere, or directly from me.
Daniel
--
daniel at island.com Daniel Smith, Island Graphics, (415) 491 0765 x 250(w)
daniel at world.std.com 4000 CivicCenterDrive SanRafael MarinCounty CA 94903
dansmith at well.sf.ca.us Fax: 491 0402 Disclaimer: Hey, I wrote it, not IG!
falling/yes I'm falling/and she keeps calling/me back again - IJSaF, Beatles
More information about the Comp.unix.questions
mailing list