1. Variable substitution within a variable name
Anyone know of a way to use embedded variable names?
i am trying to setup a shell menu for a user to be able to choose a
printer based on their location. Since their are different numbers of
printers at each location, i am trying to make it dynamic, not static.
I have tried many combinations to no avail so far.
The test script below gets a dynamic list of printers for a particular
store, then should present a menu of those printers for the user to
select. in this case, there are 4 printers so the menu displayed
should be, for example:
1 for printer store032a
2 for printer store032b
3 for printer store032c
4 for printer store032d
Not quite what I am getting.
i=1
lpstat -a | grep store032 | awk '{ print $1 }' |
while read prn
do
out{$i}=`echo ${prn}`
echo "$i for printer ${out${i}}"
i=`expr $i + 1`
done
Result of running the above script:
printer_names.sh: out1=store032a: not found
printer_names.sh: bad substitution
Anyone have a way to do this, preferably in the bourne shell?
Thanks
--
Robert A. Johnson
Systems Administrator
Cost-U-Less Inc.
8160 304th Ave. SE
Bld. 3 Suite A
Preston, WA 98050
425-222-5022 #161
425-417-2591 (cell)
2. SysAdmin magazine
3. Kornshell: Testing if environment variable exists?
4. Memory and cache-size
5. Substitution Variables
6. How to play avi files on Linux? Any tools? thanks.
7. Variable substitution in a shell script
8. solaris, jni, threads, EPERM
9. sed and variable substitution
10. environment variable for tab substitution
11. variable substitution in sh
12. Variable Substitution Question (KSH88)
13. csh variable substitution mystery