LinuxQuestions.org
Review your favorite Linux distribution.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Non-*NIX Forums > Programming
User Name
Password
Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.

Notices


Reply
  Search this Thread
Old 04-29-2004, 03:14 PM   #1
3inone
Member
 
Registered: Jul 2003
Distribution: redhat 8.0, 9.0, FC3
Posts: 32

Rep: Reputation: 15
bash'ed by case statement???


This is the script file that I am having trouble with. I have look at examples on the net and tried several different ways of getting the "if"
command to work, but inside the case statement (the "if" works fine outside the case statement) the type of error is always the same:
"syntax error near unexpected token `;' ".
I need to be able to nest more than one command inside the "if" command so doing it on one line will not help me in the long run. It must be some simple in format that i am missing - tjis has beat me up for three days and I need help. Thank you.

WOLSLEEP=""
if [ "${WOLSEND}" = yes ]; then
if [ -f /etc/sysconfig/networking/profiles/default/wakeup.conf ]; then
while read woldev woladd woldelay; do
case ${woldev} in
"#" ) continue ;;
host ) WOLSLEEP=${woldelay} ;;
eth* ) if [ "${woldev}" = "${DEVICE}" ]; then
--> /sbin/wol_wakeup ${woldev} ${woladd} ${woldelay} & ;
fi ;;
esac
done < /etc/sysconfig/networking/profiles/default/wakeup.conf
fi
if [ "${WOLSLEEP}" != "" ]; then
echo "Waiting "$WOLSLEEP" seconds for other host(s) to wake up."
sleep $WOLSLEEP
fi
fi

The line marked --> above is line 384 produces the error in the system log:

Apr 29 11:34:30 watchdog ifup: ./ifup: line 384: syntax error near unexpected token `;'
Apr 29 11:34:35 watchdog keytable:
Apr 29 11:34:35 watchdog kernel: mtrr: v1.40 (20010327) Richard Gooch (rgooch@atnf.csiro.au)
Apr 29 11:34:30 watchdog ifup: ./ifup: line 384: ` /sbin/wol_wakeup ${woldev} ${woladd} ${woldelay} & ;'

# the following lines are the in the file wakeup.conf

# The wake up lan config layout
# <device> <mac address> <delay>
# device <eth0 ... ethn or host> mac address <ff:ff:ff:ff:ff:ff>
# delay ge <0>
# The '#' must have space after it for the line to be a comment in this file
eth0 00:02:b3:2b:59:f7 180
eth0 00:02:b3:1d:05:9e 180
eth0 00:90:27:91:e3:b2 180
host ff:ff:ff:ff:ff:ff 30
 
Old 04-29-2004, 03:28 PM   #2
slakmagik
Senior Member
 
Registered: Feb 2003
Distribution: Slackware
Posts: 4,113

Rep: Reputation: Disabled
Remove the last semi-colon of the --> line. That's in the 'if' and has a newline. No semi-colon needed. Might be some other way to write all that, too.

Or just formatting - I assume you did and it just got lost in posting.
Code:
WOLSLEEP=""
if [ "${WOLSEND}" = yes ]; then
	if [ -f /etc/sysconfig/networking/profiles/default/wakeup.conf ]; then
		while read woldev woladd woldelay; do
			case ${woldev} in
				"#" ) continue 
					;;
				host ) WOLSLEEP=${woldelay}
					;;
				eth* ) if [ "${woldev}" = "${DEVICE}" ]; then
					/sbin/wol_wakeup ${woldev} ${woladd} ${woldelay} &
					fi 
					;;
			esac
		done < /etc/sysconfig/networking/profiles/default/wakeup.conf
	fi

	if [ "${WOLSLEEP}" != "" ]; then
		echo "Waiting "$WOLSLEEP" seconds for other host(s) to wake up."
		sleep $WOLSLEEP
	fi
fi
Just guessing, as I can't think how to quickly test that myself. Could be wrong. A quick butchery of it into nothingness made it exit silently whereas the semi-colon threw an error.
 
Old 04-29-2004, 04:52 PM   #3
3inone
Member
 
Registered: Jul 2003
Distribution: redhat 8.0, 9.0, FC3
Posts: 32

Original Poster
Rep: Reputation: 15
Thank you very much - that did the trick for me. Also it helps me understand some how bash thinks.
 
  


Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
problematic case statement alaios Programming 4 08-24-2005 09:05 AM
Why are all my upper case files being shown as lower case?? [Kernel 2.6.9-1.667 FC3] t3gah Fedora 4 03-11-2005 04:09 PM
Case Statement With Aix Ksh Scripting ']['HeBroken AIX 2 02-09-2005 12:44 PM
KSH Scripting case statement..... ']['HeBroken Programming 1 12-10-2004 10:38 AM
Lower case to upper case letter sudhasmyle Programming 1 12-03-2004 04:15 AM

LinuxQuestions.org > Forums > Non-*NIX Forums > Programming

All times are GMT -5. The time now is 07:26 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration