MoshiachNow
IS-IT--Management
HI,
I needed to timeout the "read" after 60 seconds,if no response received from the user,and continue the script !
I have used the timer function in background .It works - after 60 seconds the script receives the "TERM" signal.
I trap the "TERM" and issue "break",expecting it to kick me out of the loop that waits for the "read".
However - it does NOT continue,but waits for the user to hit any key on the keyboard to continue.
What is wrong?
====================================
#!/bin/ksh
Background_Timer ()
# sub funciton to run timer in the background
{
sleep 60
#10 minutes timeout
kill $$
}
Background_Timer &
#call sub function in the background
trap “break” TERM
#break the “read” loop if KILL sent by Background_Timer
echo “\nMaintenance will begin shortly, the system will logout from the CDE”
echo “\nType \”A\” to abort or \”C\” to continue : >> \c"
integer DELAY=0
while true ;do
read DECISION
if [[ $DECISION = [Aa] ]] ;then
exit 1
elif [[ $DECISION = [Cc] ]] ;then
break
else
echo “Type \”A\” or \”C\” only ! >> \c”
fi
done
trap - TERM
CONTINUE with the rest of the script ....
"Long live king Moshiach !"
h
I needed to timeout the "read" after 60 seconds,if no response received from the user,and continue the script !
I have used the timer function in background .It works - after 60 seconds the script receives the "TERM" signal.
I trap the "TERM" and issue "break",expecting it to kick me out of the loop that waits for the "read".
However - it does NOT continue,but waits for the user to hit any key on the keyboard to continue.
What is wrong?
====================================
#!/bin/ksh
Background_Timer ()
# sub funciton to run timer in the background
{
sleep 60
#10 minutes timeout
kill $$
}
Background_Timer &
#call sub function in the background
trap “break” TERM
#break the “read” loop if KILL sent by Background_Timer
echo “\nMaintenance will begin shortly, the system will logout from the CDE”
echo “\nType \”A\” to abort or \”C\” to continue : >> \c"
integer DELAY=0
while true ;do
read DECISION
if [[ $DECISION = [Aa] ]] ;then
exit 1
elif [[ $DECISION = [Cc] ]] ;then
break
else
echo “Type \”A\” or \”C\” only ! >> \c”
fi
done
trap - TERM
CONTINUE with the rest of the script ....
"Long live king Moshiach !"
h