Another BASH Scripting question
Madison Kelly
linux-5ZoueyuiTZhBDgjK7y7TUQ at public.gmane.org
Mon Feb 9 17:43:38 UTC 2004
Hi all,
Sorry for asking so many questions! I am on quite the learning curve
at the moment! :)
I am on the last portion of my firewall script and I need something
like an array (though judging from what I have read on array's, not
exactly one).
Here is what I am trying to do: I have rules for multiple servers.
Later on we will add more servers. I already will have to copy/paste the
variables and update the data for the servers but I don't want to have
to edit the actual script. To do this, I want to have the script read
the value from a variable but have part of that variable name itself be
dynamic. This is what is stumping me...
In my head, I am trying to do this:
# How many servers do we have?
SRV_NAME="SRV1 SRV2"
# Rules for server <server>
SRV1_SNAT_IP="192.168.2.10:111.222.333.44
SRV1_IB_TCP="22 25 53 80 110"
SRV1_IB_UDP="22 25 53 80 110"
SRV1_LAN_TCP="22>192.168.1.12"
SRV1_LAN_TCP="22>192.168.1.12"
# Rules for server <server>
SRV2_SNAT_IP="192.168.2.11:111.222.333.45
SRV2_IB_TCP="22 80"
SRV2_IB_UDP="22 80"
SRV2_LAN_TCP="22>192.168.1.16"
SRV2_LAN_TCP="22>192.168.1.16"
echo -n "Checking to see if we have servers: "
if [ "${SRV_NAME}" != "" ] ; then
echo "we do!"
echo "Setting up rules for each public server: "
for server in ${SRV_NAME} ; do
echo "Processing: "${server}
# Here is where things break!
echo "${server}_SNAT_IP" | {
IFS=':' read pubip inetip
echo "Internal IP: "${pubip}
echo "Internet IP: "${inetip}
}
done
fi
The output is:
Checking to see if we have servers: we do!
Setting up rules for each server:
Processing: SRV1
Internal IP: SRV1_SNAT_IP
Internet IP:
Processing: SRV2
Internal IP: SRV2_SNAT_IP
Internet IP:
So, my problem is that the variable name is becoming the value... How
can I go about getting the value of to cobbled together variable name
instead?
Thank you all so much again!!
Madison
--
The Toronto Linux Users Group. Meetings: http://tlug.ss.org
TLUG requests: Linux topics, No HTML, wrap text below 80 columns
How to UNSUBSCRIBE: http://tlug.ss.org/subscribe.shtml
More information about the Legacy
mailing list