Another BASH Scripting question

James Knott james.knott-bJEeYj9oJeDQT0dZR+AlfA at public.gmane.org
Tue Feb 10 02:34:09 UTC 2004


If you're going to e-mail a long URL, please include it in < >, so that 
it gets read as one line.  Such as:

<http://www.chapters.indigo.ca/item.asp?N=35&R=241439&act=A03&Item=978067232642&Section=books&Catalog=Books&Lang=en&mscssid=K5FHLP4657LA9M57VLK967CJM3DP54TE&WSID=21024D0DF54C3AF04228A279447B26D0E9FD1209>



pegasoft-iRg7kjdsKiH3fQ9qLvQP4Q at public.gmane.org wrote:
> Hi All,
> 
> If anyone is looking for a good read!
> 
> http://www.chapters.indigo.ca/item.asp?N=35&R=241439&act=A03&Item=978067
> 232642&Section=books&Catalog=Books&Lang=en&mscssid=K5FHLP4657LA9M57VLK96
> 7CJM3DP54TE&WSID=21024D0DF54C3AF04228A279447B26D0E9FD1209
> 
> 
> Linux Shell Scripting with Bash
> Author: Ken Burtch
> Published By: Sams
> Trade Paperback
> ISBN:0672326426
> Published: January 2004
> Usually ships in 24 hours
> List Price:$49.99
> Our Price: $34.99
> 
> Dan Braun
> 
> 
> --
> Dan Braun - PegaSoft Canada / CityTV
> danb.nospam-iRg7kjdsKiH3fQ9qLvQP4Q at public.gmane.org
> 
> 
> -----Original Message-----
> From: owner-tlug-lxSQFCZeNF4 at public.gmane.org [mailto:owner-tlug at ss.org] On Behalf Of Madison
> Kelly
> Sent: Monday, February 09, 2004 12:44 PM
> To: tlug-lxSQFCZeNF4 at public.gmane.org
> Subject: [TLUG]: Another BASH Scripting question
> 
> 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
> 
> --
> 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


--
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