- Community Home
- >
- Servers and Operating Systems
- >
- Operating Systems
- >
- Operating System - HP-UX
- >
- Assign $VAR to an array
Categories
Company
Local Language
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
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
Community
Resources
Forums
Blogs
- 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
тАО03-12-2009 08:37 AM
тАО03-12-2009 08:37 AM
I want to assign the following variables to an array but not sure if this would be the correct solution ....
I have a set of commands to run to configure and application and depending on how many $VAR will depend on the command to execute:
the variables in a seperate config file are:
ECM_SOAP=443
ECM_HTTP=7080
ECM_HTTP=7090
ECM_MAPPORT1=7843
in the script I have the following command:
dscontrol port add ${SERVICE}_CLUST:7090+7080+7843+443 method nat reset no
the problem is when I run the command in a loop to configure another environment:
(from the config file)
SIG_SOAP=444
SIG_HTTP=7180
SIG_HTTP=7190
SIG_MAPPORT1=7844
SIG_MAPPORT2=7944
how can I take these variables and execute the command
dscontrol port add ${SERVICE}_CLUST:
thanks for any help!
chris
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО03-12-2009 08:54 AM
тАО03-12-2009 08:54 AM
SolutionTO assign variables to an array you can do:
#!/usr/bin/sh
echo "Enter a series of space-delimited fields to populate ARY"
read LINE
set -A ARY ${LINE}
echo "${#ARY[*]} elements exist"
echo "element_0 = ${ARY[0]}"
echo "element_1 = ${ARY[1]}"
...
Regards!
...JRF...
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО03-12-2009 06:25 PM
тАО03-12-2009 06:25 PM
Re: Assign $VAR to an array
Config file:
SOAP=443
HTTP1=7080
HTTP2=7090
MAPPORT1=7843
Script:
. fullpath/config_file
dscontrol port add ${SERVICE}_CLUST:$HTTP2+$HTTP1+$MAPPORT1+$SOAP method nat reset no
This takes the port settings from the config file, and applies them to the script. You may consider using a variable for SERVICE in the config file.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО03-13-2009 12:40 AM
тАО03-13-2009 12:40 AM
Re: Assign $VAR to an array
PORTS=`egrep "HTTP|MAPPORT|SOAP" configfile \
| awk -F= '{if (ports=="") {ports=$2}
else {ports=ports"+"$2}
} END{print ports}'`
dscontrol port add $SERVICE_CLUST:$PORTS method nat reset no
egrep looks for all HTTP, MAPPORT and SOAP lines in your configfile
awk uses "=" as delimiter and adds the ports in one line. So you can have as many ports as you like in your configfile.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО03-13-2009 01:33 AM
тАО03-13-2009 01:33 AM
Re: Assign $VAR to an array
Chris,