simple shell script with elif and for nexxt

Hi!

I have here a simple script to change the advskew on carp interfaces. The first is working, but the part for status, where a for is within a if/else delivers everyime only the action for the value "prod". Even when i use type test or dev. Where did i made the mistake?

# $Log: switch-carp-priority.sh,v $
# Revision 1.2  2009/10/02 05:13:05  huth
# �nderungen im advskew in allen stages
#
# Revision 1.1  2009/10/01 12:27:11  huth
# initial checkin
#
#!/bin/sh
#Skript zur Veraenderung der Prioritaet der carp interfaces je stage

#Liste aller carp interfaces im produktiven stage
A="carp1" 
B='carp4'
C='carp5'
D='carp11'
E='carp12'
F='carp15'
G='carp19'
H='carp23'
I='carp30'

#Liste aller carp  interfaces im testing stage
testA='carp2 '
testB='carp3 '
testC='carp6 '
testD='carp10'
testE='carp14'
testF='carp17'
testG='carp20'
testH='carp29'
testI='carp34'

#Liste aller carp interfaces im development stage
devA='carp0 '
devB='carp7 '
devC='carp8 '
devD='carp9'
devE='carp13'
devF='carp16'
devG='carp35'

case "$1" in

    prod)
        for i in $A $B $C $D $E $F $G $H $I;do
            ifconfig "$i"
        done
        
        echo "Dies ist der aktuelle Stand im produktiven stage!"
        echo "Wollen Sie wirklich den advskew fuer den produktiven stage aendern? (y/n)"
        read Z
        echo "Geben Sie den neuen Wert f�r den advskew ein:"
        read X
        
        if [ "$Z"="y"i ] ; then
            for i in $A $B $C $D $E $F $G $H $I;do
                ifconfig "$i" advskew "$X"
               done
        else
            echo "Carpzustand wird nicht veraendert!"
        fi
        exit 0
        ;;
    
    test)
        for i in $testA $testB $testC $testD $testE $testF $testG $testH $testI;do
            ifconfig "$i"
        done
        
        echo "Dies ist der aktuelle Stand im testing stage!"
        echo "Wollen Sie wirklich den advskew fuer den testing stage aendern? (y/n)"
        read Z
        echo "Geben Sie den neuen Wert f�r den advskew ein:"
        read X
        
        if [ "$Z"="y" ] ; then
            for i in $testA $testB $testC $testD $testE $testF $testG $testH $testI;do
                   ifconfig "$i" advskew "$X"
               done
        else 
            echo "Carpzustand wird nicht veraendert!"
        fi
        exit 0
        ;;
    
    dev)
        for i in $devA $devB $devC $devD $devE $devF $devG $devH $devI;do
                ifconfig "$i"
        done
        
        echo "Dies ist der aktuelle Stand im development stage!"
        echo "Wollen Sie wirklich den advskew fuer den development stage aendern? (y/n)"
        read Z
        echo "Geben Sie den neuen Wert f�r den advskew ein:"
        read X
        
        if [ "$Z"="y" ] ; then
            for i in $devA $devB $devC $devD $devE $devF $devG $devH $devI;do
                   ifconfig "$i" advskew "$X"
               done
        else
            echo "Carpzustand wird nicht veraendert!"
        fi
        exit 0
        ;;
    status)
        echo "Welchen stage moechten Sie sich anschauen? (prod|test|dev)"
        read Y
        if [ "$Y"="prod" ]; then
            for i in $A $B $C $D $E $F $G $H $I;do
                ifconfig "$i"
            done
        elif [ "$Y"="test" ]; then
            for i in $testA $testB $testC $testD $testE $testF $testG $testH $testI;do
                ifconfig "$i"
            done
        elif [ "$Y"="dev" ]; then
            for i in $devA $devB $devC $devD $devE $devF $devG $devH $devI;do
                ifconfig "$i"
            done
        fi
        exit 0
    *)echo "Usage prod|test|dev"
        ;;
esac

Hi.

All of your if / elif statements are wrong.

The = should have spaces before and after.

i.e.

if [ "$Z" = "y" ] ; then

Is this "i" after "y" intended:

if [ "$Z" = "y"i ] ; then

Thx, it's working fine now, but i want to expand it. Maybe someone can help me with that. Is it possible to give this script a second parameter on the commandline instead of asking for the case and then for the advskew value? Something like that:

switch-carp-priority.sh prod 5

thx in advance

Alex