HPE GreenLake Administration
- Community Home
- >
- Servers and Operating Systems
- >
- Operating Systems
- >
- Operating System - HP-UX
- >
- problem with exported env. var. with index
Operating System - HP-UX
1833420
Members
3520
Online
110052
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
Forums
Discussions
Discussions
Discussions
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
Blogs
Information
Community
Resources
Community Language
Language
Forums
Blogs
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
06-29-2005 08:51 PM
06-29-2005 08:51 PM
problem with exported env. var. with index
in .profile I have:
export TESTVAR=hallo
export TESTV[1]=jaja
in truuk I have:
echo ${TESTVAR}
echo ${TESTV[1]}
I have this on two (identical) systems.
sh truuk on system A gives
hallo
jaja
but on system B it gives
hallo
So on system B ${TESTV[1]} is not known in the subshell.
The variables are known in the current shell.
It used to work on system B also, but after a reboot it doesn't anymore.
Any clues ?
export TESTVAR=hallo
export TESTV[1]=jaja
in truuk I have:
echo ${TESTVAR}
echo ${TESTV[1]}
I have this on two (identical) systems.
sh truuk on system A gives
hallo
jaja
but on system B it gives
hallo
So on system B ${TESTV[1]} is not known in the subshell.
The variables are known in the current shell.
It used to work on system B also, but after a reboot it doesn't anymore.
Any clues ?
1 REPLY 1
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-30-2005 09:48 AM
06-30-2005 09:48 AM
Re: problem with exported env. var. with index
exporting of arrays is never going to work. You really have to realize that the environment is simply an array of strings.
You can convince yourself of this by:
ARRY[0]=Zero
ARRY[1]=One
ARRY[2]=Two
PLAINVAR=Plain
export ARRY[0] ARRY[1] ARRY[2]
# now spawn a child shell
sh
# now examine the enviroment
env | pg
# You will see only ARRY=Zero
# The subscript will be gone
# You will also see PLAINVAR=Plain
If the values are not in the environment then they certainly can't be echo'ed
Now as a surprise while still in the child shell:
echo "${ARRY[0]}"
echo "${ARRY}"
echo "${PLAINVAR}"
echo "${PLAINVAR[0]}"
You will find that all of these work!
Now you could do something like this (with the original values of ARRY in the parent shell):
FAKEARRY="${ARRY[*]}"
export FAKEARRY
Now in the child process, you could
process ${FAKEARRY} to build a new array.
rebuild_array()
{
typeset -i KNT=0
while [[ ${#} -ge 1 ]]
do
ARRY[${KNT}]=${1}
shift
((KNT += 1))
done
return(0)
} # rebuild_array
rebuild_array ${FAKEARRY}
# Now in the child you should have
# ARRY[0], ARRY[1], ...
You can convince yourself of this by:
ARRY[0]=Zero
ARRY[1]=One
ARRY[2]=Two
PLAINVAR=Plain
export ARRY[0] ARRY[1] ARRY[2]
# now spawn a child shell
sh
# now examine the enviroment
env | pg
# You will see only ARRY=Zero
# The subscript will be gone
# You will also see PLAINVAR=Plain
If the values are not in the environment then they certainly can't be echo'ed
Now as a surprise while still in the child shell:
echo "${ARRY[0]}"
echo "${ARRY}"
echo "${PLAINVAR}"
echo "${PLAINVAR[0]}"
You will find that all of these work!
Now you could do something like this (with the original values of ARRY in the parent shell):
FAKEARRY="${ARRY[*]}"
export FAKEARRY
Now in the child process, you could
process ${FAKEARRY} to build a new array.
rebuild_array()
{
typeset -i KNT=0
while [[ ${#} -ge 1 ]]
do
ARRY[${KNT}]=${1}
shift
((KNT += 1))
done
return(0)
} # rebuild_array
rebuild_array ${FAKEARRY}
# Now in the child you should have
# ARRY[0], ARRY[1], ...
If it ain't broke, I can fix that.
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.
Company
Events and news
Customer resources
© Copyright 2025 Hewlett Packard Enterprise Development LP