- Community Home
- >
- Servers and Operating Systems
- >
- Operating Systems
- >
- Operating System - HP-UX
- >
- setting an array from an existing $VAR
Operating System - HP-UX
1754322
Members
2666
Online
108813
Solutions
Forums
Categories
Company
Local Language
юдл
back
Forums
Discussions
Forums
- Data Protection and Retention
- Entry Storage Systems
- Legacy
- Midrange and Enterprise Storage
- Storage Networking
- HPE Nimble Storage
Discussions
Discussions
Discussions
Forums
Forums
Discussions
юдл
back
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
- BladeSystem Infrastructure and Application Solutions
- Appliance Servers
- Alpha Servers
- BackOffice Products
- Internet Products
- HPE 9000 and HPE e3000 Servers
- Networking
- Netservers
- Secure OS Software for Linux
- Server Management (Insight Manager 7)
- Windows Server 2003
- Operating System - Tru64 Unix
- ProLiant Deployment and Provisioning
- Linux-Based Community / Regional
- Microsoft System Center Integration
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Blogs
Information
Community
Resources
Community Language
Language
Forums
Blogs
Go to solution
Topic Options
- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Printer Friendly Page
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО05-05-2009 07:43 AM
тАО05-05-2009 07:43 AM
Hi all,
I'm looking for advise on a solution I have come up with but am not sure if this is the correct way to go about it:
I may be trying to over complicate things but I am developing a wrapper script that reads from a config file which assigns an array.
here are the elements of my array:
ECM_CLUST=ECM_OAT01
set -A ECM_PORT
ECM_PORT[1]=443
ECM_PORT[2]=7943
ECM_PORT[3]=7843
ECM_PORT[4]=7080
ECM_PORT[5]=7090
The wrapper script is called with ./<scriptname>
in this case service is going to be ECM but could be SIG - there are several functions in the script that expect ${SERVICE}_.
The issue I had was assigning the array elements from ${ECM_PORTS[*]} to another array within the script function - below is the fuction
${SERVICE}_Cluster_Conf () {
SERVICE=$1
cnt=1
MAXCNT=$(eval echo \${#${SERVICE}_PORT[@]})
set -A SERVICE_PORT
while [[ ${MAXCNT} -ge ${cnt} ]]
do
eval "SERVICE_PORT[${cnt}]=\${${SERVICE}_PORT[cnt]}"
echo ${SERVICE_PORT[${cnt}]}
(( cnt += 1))
done
echo "Loading the ${SERVICE}_CLUST address/s "
dscontrol cluster add ${SERVICE}_CLUST address $CLUSIP primaryhost $PRIMIP
dscontrol port add ${SERVICE}_CLUST:`echo "${SERVICE_PORT[*]}"|tr -s " " "+"` method nat reset no
dscontrol cluster set ${SERVICE}_CLUST proportions 49 50 1 0
#
echo "Adding server machines"
dscontrol server add ${SERVICE}_CLUST:${SERVICE_PORT[1]}:$SERVER1 address $WMBIP1 mapport ${SERVICE_PORT[2]} router $AGW ret
urnaddress $RETIP
dscontrol server add ${SERVICE}_CLUST:${SERVICE_PORT[1]}:$SERVER2 address $WMBIP2 mapport ${SERVICE_PORT[3]} router $AGW ret
urnaddress $RETIP
if [[ ${MAXCNT} -gt 3 ]] ; then
cnt=4
SERVICE_MAPPORT=`expr ${SERVICE_PORT[cnt]} + 100`
while [ ${#SERVICE_PORT[@]} -ge ${cnt} ] ; do
dscontrol server add ${SERVICE}_CLUST:${SERVICE_PORT[cnt]}:$SERVER1 address $WMBIP1 router $AGW returnaddress $RE
TIP
dscontrol server add ${SERVICE}_CLUST:${SERVICE_PORT[cnt]}:$SERVER2 address $WMBIP2 mapport ${SERVICE_MAPPORT} r
outer $AGW returnaddress $RETIP
done
fi
} # ${SERVICE}_Cluster_Conf
##########################################
##########################################
the config / vars file looks like:
exndot1_sysconf () {
NETMASK1=255.255.255.0
NETMASK2=255.255.255.0
NFA=10.27.84.200
HB_ADDR=10.27.84.201
CGA=10.27.90.254
AGW=10.27.91.254
CLUSIP=10.27.90.10
RETIP=10.27.91.10
PRIMIP=10.27.84.200
WMBIP1=10.27.111.78
WMBIP2=10.27.111.79
INTER1=en1
INTER2=en2
SERVER1=wmbot1
SERVER2=wmbot2
ECM_CLUST=ECM_OAT01
set -A ECM_PORT
ECM_PORT[1]=443
ECM_PORT[2]=7943
ECM_PORT[3]=7843
ECM_PORT[4]=7080
ECM_PORT[5]=7090
SIG_PORT[1]=444
SIG_PORT[2]=7944
SIG_PORT[3]=7844
} # exndot1_sysconf
#################################
#################################
The solution have questioned myself which has taken a bit of hacking is:
SERVICE=ECM
cnt=1
MAXCNT=$(eval echo \${#${SERVICE}_PORT[@]})
set -A SERVICE_PORT
while [[ ${MAXCNT} -ge ${cnt} ]]
do
eval "SERVICE_PORT[${cnt}]=\${${SERVICE}_PORT[cnt]}"
echo ${SERVICE_PORT[${cnt}]}
(( cnt += 1))
done
443
7943
7843
7080
7090
appologies if I haven't explained well and I understand that this could be quite confusing but is there a less complicated approach I should be taking?
Thanks
Chris
I'm looking for advise on a solution I have come up with but am not sure if this is the correct way to go about it:
I may be trying to over complicate things but I am developing a wrapper script that reads from a config file which assigns an array.
here are the elements of my array:
ECM_CLUST=ECM_OAT01
set -A ECM_PORT
ECM_PORT[1]=443
ECM_PORT[2]=7943
ECM_PORT[3]=7843
ECM_PORT[4]=7080
ECM_PORT[5]=7090
The wrapper script is called with ./<scriptname>
in this case service is going to be ECM but could be SIG - there are several functions in the script that expect ${SERVICE}_
The issue I had was assigning the array elements from ${ECM_PORTS[*]} to another array within the script function - below is the fuction
${SERVICE}_Cluster_Conf () {
SERVICE=$1
cnt=1
MAXCNT=$(eval echo \${#${SERVICE}_PORT[@]})
set -A SERVICE_PORT
while [[ ${MAXCNT} -ge ${cnt} ]]
do
eval "SERVICE_PORT[${cnt}]=\${${SERVICE}_PORT[cnt]}"
echo ${SERVICE_PORT[${cnt}]}
(( cnt += 1))
done
echo "Loading the ${SERVICE}_CLUST address/s "
dscontrol cluster add ${SERVICE}_CLUST address $CLUSIP primaryhost $PRIMIP
dscontrol port add ${SERVICE}_CLUST:`echo "${SERVICE_PORT[*]}"|tr -s " " "+"` method nat reset no
dscontrol cluster set ${SERVICE}_CLUST proportions 49 50 1 0
#
echo "Adding server machines"
dscontrol server add ${SERVICE}_CLUST:${SERVICE_PORT[1]}:$SERVER1 address $WMBIP1 mapport ${SERVICE_PORT[2]} router $AGW ret
urnaddress $RETIP
dscontrol server add ${SERVICE}_CLUST:${SERVICE_PORT[1]}:$SERVER2 address $WMBIP2 mapport ${SERVICE_PORT[3]} router $AGW ret
urnaddress $RETIP
if [[ ${MAXCNT} -gt 3 ]] ; then
cnt=4
SERVICE_MAPPORT=`expr ${SERVICE_PORT[cnt]} + 100`
while [ ${#SERVICE_PORT[@]} -ge ${cnt} ] ; do
dscontrol server add ${SERVICE}_CLUST:${SERVICE_PORT[cnt]}:$SERVER1 address $WMBIP1 router $AGW returnaddress $RE
TIP
dscontrol server add ${SERVICE}_CLUST:${SERVICE_PORT[cnt]}:$SERVER2 address $WMBIP2 mapport ${SERVICE_MAPPORT} r
outer $AGW returnaddress $RETIP
done
fi
} # ${SERVICE}_Cluster_Conf
##########################################
##########################################
the config / vars file looks like:
exndot1_sysconf () {
NETMASK1=255.255.255.0
NETMASK2=255.255.255.0
NFA=10.27.84.200
HB_ADDR=10.27.84.201
CGA=10.27.90.254
AGW=10.27.91.254
CLUSIP=10.27.90.10
RETIP=10.27.91.10
PRIMIP=10.27.84.200
WMBIP1=10.27.111.78
WMBIP2=10.27.111.79
INTER1=en1
INTER2=en2
SERVER1=wmbot1
SERVER2=wmbot2
ECM_CLUST=ECM_OAT01
set -A ECM_PORT
ECM_PORT[1]=443
ECM_PORT[2]=7943
ECM_PORT[3]=7843
ECM_PORT[4]=7080
ECM_PORT[5]=7090
SIG_PORT[1]=444
SIG_PORT[2]=7944
SIG_PORT[3]=7844
} # exndot1_sysconf
#################################
#################################
The solution have questioned myself which has taken a bit of hacking is:
SERVICE=ECM
cnt=1
MAXCNT=$(eval echo \${#${SERVICE}_PORT[@]})
set -A SERVICE_PORT
while [[ ${MAXCNT} -ge ${cnt} ]]
do
eval "SERVICE_PORT[${cnt}]=\${${SERVICE}_PORT[cnt]}"
echo ${SERVICE_PORT[${cnt}]}
(( cnt += 1))
done
443
7943
7843
7080
7090
appologies if I haven't explained well and I understand that this could be quite confusing but is there a less complicated approach I should be taking?
Thanks
Chris
hello
Solved! Go to Solution.
2 REPLIES 2
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО05-05-2009 05:23 PM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО05-06-2009 01:04 AM
тАО05-06-2009 01:04 AM
Re: setting an array from an existing $VAR
great stuff cheers Dennis.
regards
Chris
regards
Chris
hello
The opinions expressed above are the personal opinions of the authors, not of Hewlett Packard Enterprise. By using this site, you accept the Terms of Use and Rules of Participation.
News and Events
Support
© Copyright 2024 Hewlett Packard Enterprise Development LP