b-shell: any better idea for this one?Thanks!!


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting b-shell: any better idea for this one?Thanks!!
# 1  
Old 09-07-2007
b-shell: any better idea for this one?Thanks!!

I'm new to the script programming and I have this piece of code (repeatedly used) in my program:

while :
do
................
ans=`ckyorn -p "Do you want to continue?"`
if [ "$ans" = "n" ] || [ "$ans" = "no" ] || [ "$ans" = "N" ] || [ "$ans" = "NO" ]; then
break
elif [ "$ans" = "q" ] || [ "$ans" = "Q" ]; then
echo "Aborting..."
exit 2 # exit code for user choice of aborting
fi
done

It works fine but I wonder if there is a simpler way to write the if block- without detailing each of the conditions. I'm sure there is but don't know what;-)
Any advice woulld be highly appreciated. Thanks in advance!!
Bluemoon
# 2  
Old 09-07-2007
you could use case .... esac

Code:
case `cykorn ....`
y | yes )
     do yes thing
     ;;
n | no )
     do no thing
      ;;
* )
     echo what?
     ;;
esac

# 3  
Old 09-08-2007
cool... thank you so much

...exactly what I wanted.
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. UNIX for Dummies Questions & Answers

Help me in just providing idea about what to be done?

Hi, I am thinking to increase my knowledge towards shell scripting and tcl scripting. The thing is, please suggest me a script which i can code is useful in learning as well as to project it to my team mates and it is helpful to all my office team mates. I'll give you an idea of what we... (4 Replies)
Discussion started by: Syed Imran
4 Replies

2. Shell Programming and Scripting

I have no idea how to solve this :/

I am trying to make a script that will execute different things by the input Input: #/bin/bash echo "Test script" read cake if then echo "cake it is" fi Output: 1 : bad variable nameake test.sh: 8: test.sh: Syntax error: end of file unexpected (expecting "then") (0 Replies)
Discussion started by: kitay
0 Replies

3. Shell Programming and Scripting

need a new idea for a script

Hi all, I now have project in UNIX Solaris and I want to have some new ideas to execute it, so I hope you help me finding new ideas in scripting or some infrastructure .bye (1 Reply)
Discussion started by: hard_revenge
1 Replies

4. Solaris

Idea for project

Hi guys I need idea ti play with Solaris :cool: I have some free time and I want to learn something new, so far I learned how to install Solaris using Jumpstart and flash archives. I'm intereted in programming and networks however my programming skills are very weak so I only can learn... (3 Replies)
Discussion started by: solaris_user
3 Replies

5. Shell Programming and Scripting

Idea for DB Password in Shell Scripts

I work in an environment where we have a Oracle DB Server on a AIX box. There are several batch scripts that load and execute on the database. The DBA wants to periodically change the password. Ideally I would like to have one common place to maintain the database as it is changed. I was thinking... (2 Replies)
Discussion started by: mode09
2 Replies

6. Shell Programming and Scripting

help... no idea what to use

my issue now is i have a txt file containing a list like below i want to create a script that will add a constant text "Find this name" at the start and "at your directory" at the end. every line should be added by phrase at the start and end. Each line of the file should look like "Find... (4 Replies)
Discussion started by: dakid
4 Replies

7. Shell Programming and Scripting

Errors-- Any Idea

Getting some errors when i run this script.. ./xml_load_process.txt: -jar: not found ./xml_load_process.txt: syntax error at line 31 : `then' unmatched any ideas...really miffed at my inability to spot the error.... #!/bin/ksh # set -o xtrace # set environment variables export... (3 Replies)
Discussion started by: jazz21
3 Replies

8. Shell Programming and Scripting

Here is an interesting idea...

Does anyone know how to test if an ethernet interface is alive, or accepting connections? Here is the scenario - I have rsc and sc console interfaces on some Suns. There are some sporadic vulnerability scans that send them out to lunch when they run the scans. I have to login to the host and reset... (0 Replies)
Discussion started by: lm_admin_dh
0 Replies

9. Shell Programming and Scripting

Echo escaped \c in SH Shell Any Idea

Hi All, I have got an echo statement with "\c" in it to avoid getting into a newline. Ths script is using #!\bin\sh Any idea what could make it to escape "\c" (4 Replies)
Discussion started by: asami
4 Replies

10. Shell Programming and Scripting

Limitations of awk? Good idea? Bad idea?

Keeping in mind that I'm relatively comfortable with programming in general but very new to unix and korn/bourne shell scripts.. I'm using awk on a CSV file, and then performing calculations and operations on specific fields within specific records. The CSV file I'm working with has about 600... (2 Replies)
Discussion started by: yongho
2 Replies
Login or Register to Ask a Question