tobold.org

correct • elegant • free

△ comp.unix.shell △

◅ How to run ksh program?? Please Help

Last argument or pid??? ▻

Shell script with a timeout...

In article <37FD0574.E03D74B1@f15ra.al.intel.com>,
Ron Peters  <rpeters@f15ra.al.intel.com> wrote:
>I want the script to ask the user something like: Do you want to do this
>certain somethine? (y/n).
>
>If there is no answer within say 10 seconds, timeout and continue on
>with the script assuming that the user wanted or didn't want to do that
>thing.

I consider this very poor User Interface design.  What happens if the
phone rings just as the question is asked?

Much better to have a default answer, but wait for the user to hit the
`return' key before proceeding.  Here's some code I've used for this.

    defsh=/bin/tcsh
    printf 'Shell? [%s] ' $defsh
    read sh
    case $sh in
    '')
            sh=$defsh
            ;;
    esac

Tim.
--
Tim Goodwin   | "People think [ W. Gibson is ] hi-tech because his prose
Leicester, UK | is as pleasant to read as a C++ program." -- JT

Original headers:

From: tjg@star.le.ac.uk (Tim Goodwin)
Newsgroups: comp.unix.shell
Subject: Re: Shell script with a timeout...
Date: 13 Oct 1999 13:23:02 +0100
Organization: University of Leicester, UK
Message-ID: <7u1tjs$7ll$1@ltpcg.star.le.ac.uk>
References: <37FCD4B6.2A7C88F9@f15ra.al.intel.com>
  <7tisfa$66k$1@nnrp1.deja.com> <37FD0574.E03D74B1@f15ra.al.intel.com>

△ comp.unix.shell △

◅ How to run ksh program?? Please Help

Last argument or pid??? ▻