Bourne Shell Scripting CRISIS


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Bourne Shell Scripting CRISIS
# 15  
Old 05-30-2002
You are also missing one set of ;; at the end of 3) in the second case statement.
thehoghunter
# 16  
Old 05-30-2002
Ok, added second ;; in 3) of second case statement, now claims that it's unexpected

Filename: syntax error at line 157: ';;' unexpected

Is the UNIX server that I'm using on drugs? Or is it just me?

Thanks
# 17  
Old 05-30-2002
Maybe the code I grabbed off here didn't have it. Just make sure for each case option, you have the same amount of ending ;;. You have 8 total option (4 options in each case) so you should have 8 ;; closing each option. Just as you had the two case statements but didn't have the closing esac statements (you fixed that).

Also, are you attempting to use 4) Quit in both case statements? That would be illegal/wrong/unadvisable.

I pulled out all the extra and just checked your code this way:

#!/bin/sh
echo "A case example"
echo ----------------
echo ---Main--Menu---
echo ----------------
echo
echo "1. Backup files"
echo
echo "2. Restore Backed-up files"
echo
echo "3. View Logs"
echo
echo "4. Quit"
echo
echo Please enter your selection
read selection
case $selection in
1)
echo "backup of file"
;;
2)
echo "Restore of files"
;;
3)
echo "Menu choices again"
echo "1. Search logs"
echo "2. View by date"
echo "3. View by type"
echo "4. Quit"
echo "Please enter your selection"
read sel1
case $sel1 in
1)
echo "Searching logs"
;;
2)
echo "Viewing logs by date"
;;
3)
echo "Viewing logs by type"
;;
4)
echo "quitting"
;;
esac
;;
4)
echo "Quitting"
;;
esac
echo "done"
exit
thehoghunter
# 18  
Old 05-30-2002
Quote:
echo You've chosen not to over-write the older file
Ummm....single quotes are special to the shell. You need to quote that quote with a backslash.
# 19  
Old 05-30-2002
G'day again

Can you see anything wrong with this? As it's still caliming that the indicated area is unexpected.

cd logs
grep B *.*
else
grep R *.*
fi
;;
** 4) #Leave the program **
exit
;;
esac
exit
4) #Drop the user back to the prompt
exit
;;
fi
exit

See if you can make any sense of it please

Thanks again
(Would've written sooner, 'cept that I needed to sleep)

Aussie_Bloke
# 20  
Old 05-31-2002
Have you tried putting the line:
set -x
at the top? It will show you what the script's doing as it runs...

I'm going to eat now, but if I get a chance later, I'll run the script, and see what I get...
# 21  
Old 05-31-2002
Thanks for all of your help everyone, but it's to no avail, the assignment (You were right LivinFree) still doesn't work, and as a result of my lack of prgamming and understanding of UNIX, it's going to be submitted as being incompleteSmilie

I wish to thank all of those who assisted in getting me this far, and I'll try to come here now and again if I can

See yas all later

Aussie_Bloke
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Cybersecurity

'Shell Shock' vulnerability in Bourne shell

A severe vulnerability was discovered in Bourne shell. Just google for: bash vulnerability ... for more details. (5 Replies)
Discussion started by: Cochise
5 Replies

2. Shell Programming and Scripting

Bourne shell & Korn shell

Could some one tell me the difference btw Bourne shell and the Kshell? Which is more flexible and reliable in terms of portability and efficiency. When i type the following command .. $ echo $SHELL yields me /bin/sh Does this tells me that I am in Bourne shell. If yes, how can i get... (6 Replies)
Discussion started by: bobby1015
6 Replies

3. Shell Programming and Scripting

Bourne/C shell help

Exercise Five Write a Bourne shell script which: • Professionalism: plan for this from the start. • Has one command line argument. • If the command line argument is a directory then the script should output the number of files in the directory. • If the command line argument is an ordinary... (2 Replies)
Discussion started by: moesom
2 Replies

4. Shell Programming and Scripting

How to activate Korn Shell functionnalities in Bourne Shell

Hi All I have writing a Korn Shell script to execute it on many of our servers. But some servers don't have Korn Shell installed, they use Borne Shell. Some operations like calculation don't work : cat ${file1} | tail -$((${num1}-${num2})) > ${file2} Is it possible to activate Korn Shell... (3 Replies)
Discussion started by: madmat
3 Replies

5. Shell Programming and Scripting

I need to understand the differences between the bash shell and the Bourne shell

I do not claim to be an expert, but I have done things with scripts that whole teams of folks have said can not be done. Of course they should have said we do not have the intestinal fortitude to git-r-done. I have been using UNIX actually HPUX since 1992. Unfortunately my old computer died and... (7 Replies)
Discussion started by: awk_sed_hello
7 Replies

6. UNIX for Dummies Questions & Answers

Bourne-again shell

Hi guys !! well i'm still new in learning UNIX , and actually i'm still studying it by myself .. anyway, some people told me the Bourne-again shell is a good version of UNIX to work on , and i tried to download yesterday but i didn't know how to start it ...... the ReadMe file associated with... (3 Replies)
Discussion started by: mrsamer
3 Replies

7. UNIX for Dummies Questions & Answers

bourne shell programming help!

hey, i have 2 files... orders and products how do i do calculations on the order using the products ? say if the products file is: a123:shirt:10.00 zz123:nice shirt:19.95 and the order file is: 05/08/30 a123 10 zz123 3 Jun-3-1994 a123 2 2005.06.23 a123 2 (1 Reply)
Discussion started by: ganjakh0r
1 Replies

8. Shell Programming and Scripting

bourne shell programming help

hey, i have 2 files... orders and products how do i do calculations on the order using the products ? say if the products file is: a123:shirt:10.00 zz123:nice shirt:19.95 and the order file is: 05/08/30 a123 10 zz123 3 Jun-3-1994 a123 2 2005.06.23 a123 2 (1 Reply)
Discussion started by: ganjakh0r
1 Replies

9. Shell Programming and Scripting

Bourne Shell scripting help

4. Write a program that will allow a user to input as many numbers as the user wants (use 999 as the choice that ends the user input). The program will then respond: Highest Number: Answer Lowest Number: Answer Sum of the numbers: Answer Average of the numbers: Answer Can any1 help... (1 Reply)
Discussion started by: PoloRL185
1 Replies

10. Shell Programming and Scripting

Bourne Shell Scripting

Hi, I'm having trouble with some UNIX Bourne shell scripting that I am doing for an assignment. I am trying to sort a comma delimited file into a sort of format that will print out nicely in a telnet terminal window. I'm having a bit of trouble because all I seem to be getting is garble. ... (3 Replies)
Discussion started by: Slamo
3 Replies
Login or Register to Ask a Question