Timed read command

Hi guys,

I love unix....but i also hate it :slight_smile:

I want to write a script that will pause in the middle ask for user input, but if no input is given i want the script to continue anyway.

Say ask a question and give 1 min to answer and if no answer at all the script continues.

Hi.

If you are using bash, then an option of interest for you is:

read -t 10 ... (other arguments)

for a 10-second limit. See man bash for details on the read statement.

Other shells may require separate functions to accomplish that task ... cheers, drl

Thanks :slight_smile:

this is what i came up with in the ned, works like a dream.

answer="No";read -p "Do you want to exit? Answer y to exit. " -t 30 answer;echo " Your answer is $answer";
if [ "$answer" = "y" ];then
echo "you have chosen to exit."
break
else
echo ""