Core iTOps Tube

Thursday, 26 April 2012

How to Exit a shell script if no input is available for 10 seconds

Hi All,

I am a new user to this forum and this is my first request.

I have a script which i am calling from crontab, i modified the code to execute directly also. I added an if condition to get user interaction in the code.This is now making the crontab call to wait for input and each time it creates new background process.




Code:


var=`find $FILENAME -newer $TIMESTAMP`

echo " Variable is $var Filename is $FILENAME"  >> $LOG_HOME/log.txt

if [ "$var" == "" ]

then

        echo "No new file available for build, Do you want to continue (Y/N) ? "

        read Choice

        if [ $Choice == "Y" ]

        then

                var=1

        fi

fi


I want to terminate (exit) the script if there is no response to the read command for 10 seconds.Can someone help me with this

I am using AIX and i don't have read -t option as given in one of the threads.




No comments:

Post a Comment