LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Programming (https://www.linuxquestions.org/questions/programming-9/)
-   -   For - in, in, an if then (https://www.linuxquestions.org/questions/programming-9/for-in-in-an-if-then-146671/)

Decoy^3 02-16-2004 06:05 AM

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. :rolleyes:
Can someone help me please?

Strike 02-16-2004 07:21 AM

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).

Decoy^3 02-16-2004 09:08 AM

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...


All times are GMT -5. The time now is 02:38 AM.