|
shell variable access
Hi
I want to do the following:
1. Create a number of Gloabla varibale "ROUTE_IP_xx" based on a counter. As xx sould be from 1-10.
ie ROUTE_IP_1
ROUTE_IP_2
.
.
ROUTE_IP_10
2. I want to initalize all of these variable to 0.0.0.0
ie ROUTE_IP_1='0.0.0.0'
3. I want to be able to access this global variable through out the code.
ie $ROUTE_IP_1
Following is waht I have got. I have generated the GLOBAL variable properly. But I could not figure out how to access them.
Please let me know if you have any suggestion?
Thanks,
Sabina
#!/bin/sh
ROUTE_MAX_NO_OF_ENTRY=10
count=1
while [ $count -le $ROUTE_MAX_NO_OF_ENTRY ]
do
ip_addr=ROUTE_IP_${count}
echo "ip_addr $ip_addr"
export $ip_addr='0.0.0.0'
tmp=`echo '$'$ip_addr`
echo $tmp
count=`expr $count + 1`
done
|