I have this script in which i ned to store employee codes in an array. So i do this using associative arrays as follows
EmpArr["AD"]="Administration"
EmpArr["MK"]="Marketing"
EmpArr["AC"]="Accounting"
the problem is when i try to extract the employee code description depending on the user input the array seems always read the last a value that is accounting. i do the following to gather the user input and then check to see using multiple if statements:
print "Enter employee code "
read empcode
If [[ $empcode == "AD" ]]
then
print "the employee code description is ${EmpArr[$empcode]}"
elif [[ $empcode == "AC" ]]
then
print "the employee code description is ${EmpArr[$empcode]}"
elif [[ $empcode == "MK" ]]
print "the employee code description is ${EmpArr[$empcode]}"
else
print "Have anice day !"
fi
Am i doing something wrong here. I'm new to UNIX so pardon me if this a very stupid question. But i really can't figure out what's wrong
Please help
EmpArr["AD"]="Administration"
EmpArr["MK"]="Marketing"
EmpArr["AC"]="Accounting"
the problem is when i try to extract the employee code description depending on the user input the array seems always read the last a value that is accounting. i do the following to gather the user input and then check to see using multiple if statements:
print "Enter employee code "
read empcode
If [[ $empcode == "AD" ]]
then
print "the employee code description is ${EmpArr[$empcode]}"
elif [[ $empcode == "AC" ]]
then
print "the employee code description is ${EmpArr[$empcode]}"
elif [[ $empcode == "MK" ]]
print "the employee code description is ${EmpArr[$empcode]}"
else
print "Have anice day !"
fi
Am i doing something wrong here. I'm new to UNIX so pardon me if this a very stupid question. But i really can't figure out what's wrong
Please help