Yes Logic


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Yes Logic
# 1  
Old 05-31-2009
Yes Logic

Dear All,

Pleae help me guiding a way to create a logic where when someone try to run a script manually, some general instruction should be displayed first, if user agrees all those instruction and further wants to execute the script he/she should type "YES". After enterning "YES" than script should executed otherwise it should exit.Smilie

For the case of instruction i can display them easily, just i need the logic for "YES"

Please advice...Smilie

Waiting anxiously Smilie
# 2  
Old 05-31-2009
you can use logic like conditional test on input data
using IF,CASE,WHILE etc... its better to use CASE..
# 3  
Old 05-31-2009
Thankz vidyadhar85,

It would be better if u write a code for it for my better understanding.

Thankz in advance.Smilie
# 4  
Old 05-31-2009
try something like this
Code:
echo "enter your ans:\c"
read ans
case "$ans" in
"YES"|"Y" );;
*)echo "wrong input";;
esac

# 5  
Old 05-31-2009
Thankz a lot for the reply it worked

but now the problem is that when it write anyting without "YES" or "Y" (e.g NO) the script, do execute, whereas i want if user write anything except "YES" or "Y" the script exist without executing the rest commands.


For this case i wrote (esac) at the end of the script, also at the place where you wrote in both cases scripts gets executed..

Please advice from this prespective.
# 6  
Old 05-31-2009
write exit in * of case
*)exit;;
# 7  
Old 05-31-2009
Code:
echo "enter your ans:\c"
read ans
case "$ans" in
"YES"| "Y") echo "ok ro proceed" ;;
*)echo "wrong input..exiting"; exit 1;;
esac
date


-Devaraj Takhellambam
Login or Register to Ask a Question

Previous Thread | Next Thread

1 More Discussions You Might Find Interesting

1. UNIX for Dummies Questions & Answers

Need help in logic

I have big large snapshot file which contains every process start time and end time. One server snapshot contains many Application handle. My task is to identify the process id for which the end time is not there or empty also if the completion time is not on the same date then I need to kill. ... (6 Replies)
Discussion started by: senthilkumar_ak
6 Replies
Login or Register to Ask a Question