help with assigning multiple values to a variable

I have a situation where my variable needs to pick up any of the 4 values from the environment it is in

for e.g i am on server named a

server=a (script running on this server)
ftp servers= b c d e ----- the parameter passed should be any of these values in these 4 values, if not throw an error

i will pass the ftp server as a parameter. so the idea is it should not allow anyother value apart from the ftp servers allowed if i am running from SERVER A

can I acheive this with a case statment and how do i assign the variable values?

What shell are you using?

If your using bash, set extglob option:

#!/bin/bash
ftp_servers="b|c|d|e"
 
shopt -s extglob
case $1 in
    @($ftp_servers)) echo "server OK" ;;
    *) echo "Invalid server: $1" ;;
esac
shopt -u extglob

With ksh93 just put var straight in the case:

#!/bin/ksh93
ftp_servers="b|c|d|e"
 
case $1 in
    $ftp_servers) echo "server OK" ;;
    *) echo "Invalid server: $1" ;;
esac

otherwise, you can eval it, but it's pretty messy especially if you have any sort of complex code within the case,
I'd tend to call functions rather that putting too much code in there:

ftp_servers="b|c|d|e"
 
eval "case \$1 in
    $ftp_servers) echo \"server OK\" ;;
    *) echo \"Invalid server: \$1\" ;;
esac"

i am using ksh

Think you're stuck with the 3rd version then (ie using eval on your whole case statement).