Time Out condition

Hi All,

I need a shell script for getting the input values within a particular time. say for eg. 60 sec. If the user did not give value with in the time limit,then it should display as time out.

Thanks in advance for your kind help :slight_smile:

UPDATE: itkamaraj 's solution below is much more sensible if you are writing a bash script
[strike]Fork and send a sig alarm after 60 from the child then the trap for the sig alarm is to use the default value/terminate with a request to attend the process in future[/strike]

Fork command is new to me..
Could u plz show coding for that..

Thanks in advance for your help

man read

check the -t option

yet i did not get a clear idea there. :frowning:

Its something like below..

#!/bin/ksh
echo "type something.."
read -t 10 var1 # wait for 10 seconds
if [[ -n $var1 ]]
then
        echo "you have entered: $var1"
else
        echo "time is out"
fi
1 Like