- Community Home
- >
- Servers and Operating Systems
- >
- Operating Systems
- >
- Operating System - HP-UX
- >
- Evaluate a variable within a string
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
07-10-2003 07:34 AM
07-10-2003 07:34 AM
I try to manage some logfiles' sizes with a script and a parameter file.
The parameter file contains information (separated by |) about the logfiles :
- where the logfile is,
- the maximal size I want it to be before archiving,
- etc.
The script read these information for each logfile with a 'read' command and execute the appropriate action (delete, move...).
My problem is the following : if I want to use variables within my parameter file (ex: $MY_APP_LOG), the script does not evaluate it and looks for a file named $MY_APP_LOG, which it does not find. Of course I source the adequate file before reading my parameter file (echo $MY_APP_LOG within the script works correctly).
How can I have my variables being evaluated?
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-10-2003 07:40 AM
07-10-2003 07:40 AM
Re: Evaluate a variable within a string
try with
eval <.... all your previous string...>
this cause the evaluation of the variables.
And put the variable between parentesis, it's best.
eval .....${MY_APP_LOG}......
HTH,
Massimo
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-10-2003 02:01 PM
07-10-2003 02:01 PM
Re: Evaluate a variable within a string
Perhaps this code snippet may help.
#!/usr/bin/sh -x
while read line
do
IFS='|' eval set -- \"${line}\"
echo $@
done < paramfile
Where paramfile contains
some|pipe|delimited|text
for|one|log|file|per|line
If the parameter list is included in the script as a here-document, then this would be sufficient:
while read line
do
IFS='|' set -- $line
echo $@
done <
EOF
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-11-2003 12:49 AM
07-11-2003 12:49 AM
Re: Evaluate a variable within a string
Jordan, your solution works fine, but is there a simple and elegant way to affect the different fields of the line to different variables within the script?
With the first version of my script I used :
while read NAME LOCATION MAX_SIZE
do
...
done < parmfile
I do not find nothing else than keeping my loop as it is and then use your solution locally :
eval set -- ${NAME}
NAME=`echo $@`
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-11-2003 11:50 AM