Using an array with a case statement in KSH

Hi,

I'm really new ro shell scripting (actually any kind of programming) and am pretty sure I'm making a pretty basic error here but I can't for the life of me figure it out.

What I'm trying to do is get an array working with a case statement in a KSH script. The code is as follows:

set -A zone `zoneadm list | grep -v global`
 
PS3="Enter choice:"
 
select zone_menu in ${zone
[*]} "All" "Exit"
 
do
   case $zone_menu in
 
                    ${zone[]})
                        print ${zone[$REPLY-1]};;
 
                    All)
                        print ${zone
[*]};;
 
                    Exit)
                        break ;;
   esac
done
 

So far what the above does right is that it takes the list of zones on a Solaris 10 box (minus the global zone) and inputs these into an array. I've no problem generating the list od options for the case statement using the array but it seems to be imposible to get the correct output from the case selection. I can basically get the correct output from the first option, the ALL option and the Exit option but nothing else works.

Does what I say make any sense and if so, can someone please help me? It's driving me bannanas! :wall:

Thanks in advance,

Steve

---------- Post updated at 05:12 PM ---------- Previous update was at 04:31 PM ----------

I just did the following:

...
do
   case $zone_menu in
 
                    ${zone[$REPLY-1]})
                        print ${zone[$REPLY-1]};;
 
                    All)
                        print ${zone
[*]};;
...

I was looking right at it. :o

Steve

P.S.: Bloody Azerty keyboards!!!

You're doin' great for a scripting newb.

The do ... done are not necessary here.

Thanks for the reply otheus and thanks for the compliment. I've been working hard to get over what I consider the last barrier to my carrier as a sys-engineer.

I tried to leave the do...done out but the interpreter doesn't see the case statement coming and it exits.

The script has grown to over 200 lines (including comments) and so far so good. I've one issue with an if... elif... else statement but I'll have a hunt around to see what I can find on the forums before posting anything here.

Cheers,

Steve

Ahhh... the select command requires the do..done. That's a new one to me. *hattip*