- Community Home
- >
- Servers and Operating Systems
- >
- Operating Systems
- >
- Operating System - HP-UX
- >
- Re: script issue regarding variables
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-05-2003 10:45 PM
11-05-2003 10:45 PM
I'm writing a script and I have a problem with variables assignements. Here is what I want to do :
#!/usr/bin/sh
LISTE_USER1="john gérard raoul"
LISTE_USER2="vincent gaston"
for USER in ${LISTE_$1}
do
.....
And the script is meant to be called with a variable : for example
# script.sh USER1
The problem is that ${LISTE_$1} doesn't work.
I get a "bad substitution" error message.
Do you have a solution for this ?
Thanks,
T
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-05-2003 11:00 PM
11-05-2003 11:00 PM
Re: script issue regarding variables
for USER in LISTE_$1; do
echo \$$USER
done
do something useful instead of echo in the loop body with the variable
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-05-2003 11:08 PM
11-05-2003 11:08 PM
Re: script issue regarding variables
to have the loop variable evaluated in a command you might prepend the "eval" command in your loop body where you reference the variable USER.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-05-2003 11:38 PM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-05-2003 11:40 PM
11-05-2003 11:40 PM
Re: script issue regarding variables
LISTE_USER[1]="john grard raoul"
LISTE_USER[2]="vincent gaston"
for USER in ${LISTE_USER[$1]}
do
echo $USER
done
Obviously this then gets called with arguments of 1, 2 etc
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-05-2003 11:59 PM
11-05-2003 11:59 PM
Re: script issue regarding variables
Tom