SysAdminUnix
MIS
Hi,
I'm trying to create a script with a variable array. First I'll set the array's. After that I'm going into a loop so I can call all three array's in one pass.
set -A system1 250 1.2.3.4 routerUS01.nl.com
set -A system2 250 2.3.4.5 router2501.nl.com
echo ${system1[0]}"; "${system1[1]}"; "${system1[2]}"."
typeset -i arraywaarde=1
while [ ${arraywaarde} -lt 3 ]
do
vrarray0=\$\{system${arraywaarde}"[0]"\}; echo ${vrarray0}
vrarray1=\$\{system${arraywaarde}"[1]"\}; echo ${vrarray1}
vrarray2=\$\{system${arraywaarde}"[2]"\}; echo ${vrarray2}
arraywaarde=${arraywaarde}+1
done
When I execute the script, I get the following results:
250; 1.2.3.4; routerUS01.nl.com.
${system1[0]}
${system1[1]}
${system1[2]}
${system2[0]}
${system2[1]}
${system2[2]}
I expected to get:
250; 1.2.3.4; routerUS01.nl.com.
250
1.2.3.4
routerUS01.nl.com
250
2.3.4.5
router2501.nl.com
Why am I getting the name of the variable instead of the value? How can this be solved. I tried lots but nothing seems to work anymore.
I'm trying to create a script with a variable array. First I'll set the array's. After that I'm going into a loop so I can call all three array's in one pass.
set -A system1 250 1.2.3.4 routerUS01.nl.com
set -A system2 250 2.3.4.5 router2501.nl.com
echo ${system1[0]}"; "${system1[1]}"; "${system1[2]}"."
typeset -i arraywaarde=1
while [ ${arraywaarde} -lt 3 ]
do
vrarray0=\$\{system${arraywaarde}"[0]"\}; echo ${vrarray0}
vrarray1=\$\{system${arraywaarde}"[1]"\}; echo ${vrarray1}
vrarray2=\$\{system${arraywaarde}"[2]"\}; echo ${vrarray2}
arraywaarde=${arraywaarde}+1
done
When I execute the script, I get the following results:
250; 1.2.3.4; routerUS01.nl.com.
${system1[0]}
${system1[1]}
${system1[2]}
${system2[0]}
${system2[1]}
${system2[2]}
I expected to get:
250; 1.2.3.4; routerUS01.nl.com.
250
1.2.3.4
routerUS01.nl.com
250
2.3.4.5
router2501.nl.com
Why am I getting the name of the variable instead of the value? How can this be solved. I tried lots but nothing seems to work anymore.