Home
| Calendar
| Mail Lists
| List Archives
| Desktop SIG
| Hardware Hacking SIG
Wiki | Flickr | PicasaWeb | Video | Maps & Directions | Installfests | Keysignings Linux Cafe | Meeting Notes | Linux Links | Bling | About BLU |
Bob Keyes writes: > On 10 Feb 2004, Kevin D. Clark wrote: > > Obviously, there are more complicated ways to do this as well. > > Hrm... Something like this comes to mind: #!/bin/sh # ash? # pass this two arguments: # first argument: default value if timeout occurs # second argument: timeout timed_read() { trap "echo TIMEOUT ; timed_read_result=$1; return" USR1 child=`sh -c "(sleep $2; kill -USR1 $$) 1>&- 2>&- & echo \\$\\$"` read timed_read_result kill $child 1>&- 2>&- return } echo -n "Initiate self-destruct sequence? " timed_read n 2 echo timed_read_result is $timed_read_result exit 0 Note: this is a quick hack. It needs polishing. Since I don't work with ash too often, it seems prudent to let you do the polishing. Hope this helps, --kevin -- Kevin D. Clark / Cetacean Networks / Portsmouth, N.H. (USA) cetaceannetworks.com!kclark (GnuPG ID: B280F24E) alumni.unh.edu!kdc
BLU is a member of BostonUserGroups | |
We also thank MIT for the use of their facilities. |