LinuxQuestions.org
Latest LQ Deal: Latest LQ Deals
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 02-16-2004, 06:05 AM   #1
Decoy^3
LQ Newbie
 
Registered: Jan 2004
Location: Nordland, Norway
Distribution: Slackware 9.1
Posts: 5

Rep: Reputation: 0
For - in, in, an if then


Hi!

I am having a little problem with a menu driven administration script. The part I am working on right now is for downloading and uploading configuration files to other hosts, but it is not the up- and downloading that is the problem. It is the menu:

echo -n "Hvor skal den nye konfigurasjonen brukes [(s)amme,(g)ruppe,(e)nkel]: "
read where
case $where in
[Ss])
./upconfig $1 $ip $pass;;
[Gg])
echo
while ls -l ./ipgroups | more
echo -n "Hvilken gruppe [blank for ny liste]: "
read gruppe
if [ -x ./ipgroups/$gruppe ]; then
for host in ./ipgroups/$gruppe
do
./upconfig $1 $host $pass
done
else
:; fi;; <-- Line 107....
[Ee])
echo
echo -n "Skriv inn IP-adressen: "
read ip
./upconfig $1 $ip $pass;;
esac

This is a small part of the script where the user is prompted about where to upload the configuration files. The [Gg]-case allows for uploading to a list of IPs contained in a file.
However the script refuses to fun with this error message:

./admin: line 107: syntax error near unexpected token `;;'
./admin: line 107: ` :; fi;;'

I am pretty sure the problem lies in the if-then and for-in above line 107, but I am way to newb to spot the problem.
Can someone help me please?
 
Old 02-16-2004, 07:21 AM   #2
Strike
Member
 
Registered: Jun 2001
Location: Houston, TX, USA
Distribution: Debian
Posts: 569

Rep: Reputation: 31
It doesn't look like you are doing anything in your else block ... which would mean that it's unnecessary (and probably a syntax error).
 
Old 02-16-2004, 09:08 AM   #3
Decoy^3
LQ Newbie
 
Registered: Jan 2004
Location: Nordland, Norway
Distribution: Slackware 9.1
Posts: 5

Original Poster
Rep: Reputation: 0
Well, actually, the if block never worked before I added the else statement. I was kind of spooked to find that I had to add the else to make it work. Judging from your response, it should not be neccessary. Which makes me happy for bash, and sad for my script which really must be totally fucked up somehow.

Well removing it sure does not help anything, and should not cause a syntax error either. Since it is followed by ":", as in null, or "do nothing and move on".
Thanks for the suggestion, but it did not quite do it. Anyone else?

Btw, sorry about the poor readability of my code. I couldn't find any way to add whitespace to the beginning of the lines here. Forum newb too. Heh...
 
  


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



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

All times are GMT -5. The time now is 12:07 AM.

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