- Community Home
- >
- Servers and Operating Systems
- >
- Operating Systems
- >
- Operating System - HP-UX
- >
- Building an environment file
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
Forums
Discussions
Discussions
Discussions
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
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
11-11-2006 02:44 PM
11-11-2006 02:44 PM
.environment
and it contains the following:
dirs="scripts scripts-log menu monitoring processes functions scripts main-log"
for minuscula in `echo $dirs`
do
mayuscula=`echo $minuscula | tr "[:lower:]" "[:upper:]"`
if [[ $minuscula = "scripts-log" ]]
then
${minuscula}="${HOME}/SCRIPTS/${1}/LOG"
else
${minuscula}="${HOME}/$mayuscula"
fi
done
mails="dm@yahoo.com.mx hola@yahoo.com.mx"
hn-server=$(hostname)
but the output the following is:
$ . ./.environment 0001-Alert-Temperature
ksh: scripts=/home/DRTEAM01/SCRIPTS: not found
ksh: scripts-log=/home/DRTEAM01/SCRIPTS/0001-Alert-Temperature/LOG: not found
ksh: menu=/home/DRTEAM01/MENU: not found
ksh: monitoring=/home/DRTEAM01/MONITORING: not found
ksh: processes=/home/DRTEAM01/PROCESSES: not found
ksh: functions=/home/DRTEAM01/FUNCTIONS: not found
ksh: scripts=/home/DRTEAM01/SCRIPTS: not found
ksh: main-log=/home/DRTEAM01/MAIN-LOG: not found
ksh: hn-server=torpdbp: not found
Why does appears that mistake?
it supposes that it must shows the assigned, does not it?
Please help.
Thanks.
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-12-2006 12:43 AM
11-12-2006 12:43 AM
Re: Building an environment file
${minuscula}="${HOME}/SCRIPTS/${1}/LOG"
${minuscula}="${HOME}/$mayuscula"
are incorrect. Assignments for variable must list the variable name, not the contents. When you put $ or ${} around a variable name, the shell replaces the variable name with the contents of the variable. The lines should read:
minuscula="${HOME}/SCRIPTS/${1}/LOG"
minuscula="${HOME}/$mayuscula"
Bill Hassell, sysadmin
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-12-2006 06:01 AM
11-12-2006 06:01 AM
Re: Building an environment file
in addition to Bills correct solution:
Having set
dirs="scripts scripts-log menu monitoring processes functions scripts main-log"
... there is no need to use such a construction:
for minuscula in `echo $dirs`
do ...
done
Better and simpler just use
for minuscula in $dirs
do ...
done
mfG Peter
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-12-2006 02:57 PM
11-12-2006 02:57 PM
Re: Building an environment file
but i need to put $minusucula because every time it must be:
scripts="${HOME}/SCRIPTS"
scriptslog="${HOME}/SCRIPTS/${1}/LOG"
menu="${HOME}/MENU"
monitoring="${HOME}/MONITORING"
processes="${HOME}/PROCESSES"
functions="${HOME}/FUNCTIONS"
scripts="${HOME}/SCRIPTS"
mainlog="${HOME}/MAINLOG"
it's because the contents of the variable is the value of "dirs" ....
i can not put :
minuscula="${HOME}/$mayuscula"
i need to put
$minuscula="${HOME}/$mayuscula"
where the first time minuscula would be:
minuscula=scripts
scripts=/home/DRTEAM01/SCRIPTS
minuscula=scriptslog
scriptslog=/home/DRTEAM01/SCRIPTS//LOG
minuscula=menu
menu=/home/DRTEAM01/MENU
and go on ....
what could i built this lines???
Regards.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-12-2006 06:50 PM
11-12-2006 06:50 PM
Solutionto get a variable name depending on a variable, you could use
for minuscula in $dir
do
eval $minuscula=$dir
...
done
BUT: this will NOT work for the values
dir=main-log
dir=hn-server
since a variable name cannot contain a dash '-'.
Better use arrays and access the pairs of the requested values through equal indices.
Example:
set -A dir scripts scripts-log menu monitoring processes functions scripts main-log
typeset -i idx=0 asize=0
set -A mayuscula $(typeset -u mayus
for mm in ${dir[*]}
do
mayus=$mm
if [[ $mm = "scripts-log" ]]
then print ${HOME}/SCRIPTS/${1}/LOG
else print ${HOME}/$mayus
fi
done
)
asize=${#dir[*]}
while [ idx -lt asize ]
do
print dir=${dir[idx]} mayuscula=${mayuscula[idx]}
((idx+=1))
done
The latter is just an output of the coresponding array values - put your code here.
mfG Peter
PTW: the code is untested ...