• Reading user input (w/tim

    From Khelair@DIGDIST/BATTLEST/FREEWAY to All on Monday, December 23, 2013 22:33:00
    Okay, I'm working on some failsafe scripts for my new OpenBSD 5.4 server upon which I run my BBS and a few other externally facing applications and ports. I'm trying to limit my shell scripting to the leanest & most common denominator for shell scripts, /bin/sh (at least on OpenBSD systems), which is pretty much compatible with the Bourne shell, but missing little bits here and there. One such feature that it is missing is the timeout flag on the read command. Having this available in this script is very important for me. The system is to come up and bring a bunch of services online, but a portion of these services reside on a fully encrypted partition. I want to be able to read user input from the terminal, but if nobody has been at the keyboard for 'x' number of seconds, I want to fail that or otherwise indicate no input was provided, and then continue starting other subsystems that don't reside on such a secure partition.
    I've seen a lot of web hits utilizing tools that I don't really have the luxury of, and by far the majority of them try to use 'read' with the timeout option set. I've seen a couple of other ways to do this, though. I just can't find the web hits for them now. One was utilizing a command called 'line', which also doesn't seem to exist on stock OpenBSD systems, and there was one other one that utilized 'stty' quite a bit that looks really horrifying. Does anybody have a clue what might be the best way to go about this utilizing stock OpenBSD utilities?
    If nothing else, maybe I'll have to bite the bullet and switch to the /bin/ksh shell (pdksh); I know that that has some built in timeout for user input functionality. I am really not fond of the extra memory usage and incompatibility across *NIX boxen with that solution, though.
    Anything you might be able to suggest would be very much appreciated. Other than python, perl, php, or ruby, that is. ;) Lean 'n mean, and I meant it. :)
    TIA

    --Damo dice, "Perhaps today IS a good day to die!"

    ---
    þ Synchronet