Bourne Shell Scripting CRISIS


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Bourne Shell Scripting CRISIS
# 1  
Old 05-30-2002
Error Bourne Shell Scripting CRISIS

Smilie Smilie Smilie

G'day all

This is a desperate call to those out there who know anything about Bourne Shell scripting, as I'm in the middle of a crisis

Pleae E-Mail me if you believe you can help (No spamming please)

The sooner the better, if you're an aussie that lives in Victoria, I'll even try to get you a six-pack of VB.
(That's an incentive alright! Hahahahaha)

Thankyou all very much

Aussie_Bloke

Smilie Smilie Smilie
# 2  
Old 05-30-2002
Pls read the forum rules

https://www.unix.com/unix-for-beginners-questions-and-answers/2971-simple-rules-unix-com-forums.html

(10) Don't post your email address and ask for an email reply. The forums are for the benefit of all, so all Q&A should take place in the forums.

Anyway what is the question about bourne shell ? you can try post it for us to help, not asking for email reply's.
# 3  
Old 05-30-2002
G'day

The problem that I've got is that I've written a Bourne Shell script, complete with case statements, and it seems that UNIX believes that there's a part missing.

The error that I receive (Ungratefully) is:
syntax error: ;; unexpected
Or at least something to the tune of this, as I know that it's dealing with the case statement, the only question is where I may be wrong, any suggestions anyone?

The only reason that I'm putting this up here is because the ;; that is being referred to is supposedly at the end of the file, where no such symbol / expression exists?

I'm beginning to think that the system is hallucinating.....

Any suggestions as to what the problem might be?
Is the system really on LSD? or is it just my s***ty programming?

Thanks all

Aussie_Bloke
# 4  
Old 05-30-2002
Are your case statements correct?
They follow the format:
Code:
case $something_here in
whatever_1) something_else_here ;;
whatever_2) something_else_else_here ;;
esac

Also, if you have unmatched " or ' marks anywhere in there, it could be messing you up there somewhere...

Can you post parts of the actual case statement and surrounding code?

[On a side note: I noticed that this is very likely a homework assignment based on your email address... I guess it's not as bad as asking someone to write the script for you, but generally it's not cool to post homework questions. I'm willing to help troubleshoot as long as you write the code yourself, though]
# 5  
Old 05-30-2002
G'day LivinFree

The case statement that is out of sorts is actually within another case statement, would that possible have any effect on the outcome, given that there's 4 items to choose from in both?

Another possibility could be that I'm using windows notepad to create the file, porting it to UNIX via FTP to a local server, could that create problems?

I've also noticed that even though I'm sending the same file the file sizes are different, under dos and UNIX. The difference varies, but it's not more than 100 bytes, should that be cause for concern?

As requested, here's an edited selection of the file:

Code:
        echo -----------
	echo -Logs-Menu-
	echo -----------
	echo
	echo "1. Search Logs for a file"
	echo
	echo "2. View all sorted by date / time"
	echo
	echo "3. View by type (Backup or Restore)"
	echo
	echo "4. Quit"
	echo
	echo Please make your selection
	read selection
	case $selection in
	1) #Search logs for something
	echo Please enter a file name to search for
	read searchname
	cd logs
	grep $searchname *.*
	grep $searchname >> log_file2
	;;
	2) #View all sorted by date / time
	echo Displaying all log files
	more *.*
	;;
	3) #View by type
	echo Please enter what type you want
	echo "(B for backup or R for restore)"
	read choice
	if [ $choice = "B" ]
	then
	cd logs
	grep B *.*
		else
		grep R *.*
	;;
	4) #Quit
	done
	quit
	exit
	;;

esac
4) #Quit
exit
;;
esac

The text at the bottom (The 4) #Quit portion) is the last part of the first case statement.

Note that I'm now also getting another message, claiming that the indicated line (** Code **) has an unexpected `)'
Just wondering if it would be possible to explain that one too...

Thanks

Aussie_Bloke

[I added code tags for readability....Perderabo]

Last edited by Perderabo; 05-30-2002 at 11:36 AM..
# 6  
Old 05-30-2002
The "if" statement that you posted is wrong...you need a "fi to end it.
Code:
if [ $choice = "B" ]
then
    cd logs
    grep B *.* 
else
    grep R *.*
fi

# 7  
Old 05-30-2002
Sorry mate

Should've told yas sooner, I've already found that one

Thanks anyways

Still doesn't work though, claims that there's an unexpected `)'
(Indicated with ** Code **)
Somewhere in there

then
cd logs
** grep B *.*
else
grep R *.*
;;
4) #Quit **
done
quit
exit
;;

esac
4) #Quit
exit
;;
esac

Thanks for your help, as it's both needed and greatly apprecitaed

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

Featured Tech Videos