![]() |
|
|
google unix.com
|
|||||||
| Forums | Register | Forum Rules | Links | Albums | FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read |
| Shell Programming and Scripting Post questions about KSH, CSH, SH, BASH, PERL, PHP, SED, AWK and OTHER shell scripts and shell scripting languages here. |
More UNIX and Linux Forum Topics You Might Find Helpful
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| how to access a variable value | satish@123 | Shell Programming and Scripting | 4 | 05-19-2008 05:33 AM |
| PHP Shell, for secure remote access when SSH isn't available | iBot | UNIX and Linux RSS News | 0 | 02-19-2008 05:50 AM |
| Shell access | CerialPhreak | UNIX for Dummies Questions & Answers | 2 | 08-04-2006 05:07 PM |
| shell access, please help! | genzai | UNIX for Dummies Questions & Answers | 4 | 11-18-2005 07:06 PM |
| Shell Access | turbohacker | Shell Programming and Scripting | 10 | 03-18-2004 09:39 PM |
![]() |
|
|
LinkBack | Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
|
|
||||
|
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 |
|
||||
|
Try an array: Code:
#!/bin/ksh
ROUTE_MAX_NO_OF_ENTRY=10
# make an array with 11 (0 thru 10) elements use the last ten
# elements
set -A ip_addr \
'0.0.0.0' \
'0.0.0.0' \
'0.0.0.0' \
'0.0.0.0' \
'0.0.0.0' \
'0.0.0.0' \
'0.0.0.0' \
'0.0.0.0' \
'0.0.0.0' \
'0.0.0.0' \
'0.0.0.0'
# print the array
integer i=0
while (( i <= ${#ip_addr[*]} ))
do
print "ip_addr[$i]= ${ip_addr[i]}"
let i=i+1
done
|
![]() |
| Bookmarks |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|