Operating System - HP-UX
1833315 Members
2901 Online
110051 Solutions
New Discussion

Re: regarding my previous question on shell programming

 
M. Z. Harbi
Advisor

regarding my previous question on shell programming

Hi again,

regarding my last question on the skip sequence, I tried to use some of the solution mentioned. but it seems that they are not the right ones...
the user "hpux" gave a better explanation of my problem.. "I'm waiting for your full answer"

which is:
Before go to next step, system give a prompt "Do you want to continue? (Y/N)", this prompt will keep 10 seconds(for example) to wait a user to input 'Y' or 'N', if time exceed, system set the default input 'N' and go to next step.

I hope now you could help me better...

Regards,
Mohammed Z. Harbi
UNDERSTAND life. Do NOT just STAND UNDER it...
4 REPLIES 4
curt larson_1
Honored Contributor

Re: regarding my previous question on shell programming

in="no"

print "Do you want to continue? (Y/N)"
print "-> \c"
in=$(line -t 10)

case $in in
[Y|y]*) in="yes" ;;
esac

if [[ "$in" = "yes" ]] then;
#do this
fi

#next step
John Meissner
Esteemed Contributor

Re: regarding my previous question on shell programming

I think this should take care of your needs. It builds on my previous post.....


echo "Do you want to continue"
answer=`line -t 30`
if [ "$answer" = "" ] || [ "$answer" = "n" ] || [ "$answer" = "no" ];
then exit
elif [ "$answer" = "y" ] || [ "$answer" = "yes" ] ;
then
#rest of script
fi
All paths lead to destiny
Ollie R
Respected Contributor

Re: regarding my previous question on shell programming

Hi,
The magical command is "line".
Usage :
ANS=`line -t 5`
will allow 5 seconds for an answer and then carry on running the script.
Cheers,
Ollie.
To err is human but to not award points is unforgivable
M. Z. Harbi
Advisor

Re: regarding my previous question on shell programming

Thank you all, your answers were really helpful this time...

Regards,
Mohammed Z. Harbi
UNDERSTAND life. Do NOT just STAND UNDER it...