If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

 
Go Back  dBforums > Data Access, Manipulation & Batch Languages > Unix Shell Scripts > Accessing dynamically assigned arrays

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old 08-29-07, 10:15
gendokai gendokai is offline
Registered User
 
Join Date: Aug 2007
Posts: 2
Accessing dynamically assigned arrays

Hi,

I trying to create a shell script that will create a number of arrays named after list from a text file, and then to populate the new created arrays with the contents of another file that has some associations with the first....


...this bit is not the problem:-

for name in $Adminlist # name is individual admin name
do
Nodes=`cat $Source | grep $name`

set -A $name $Nodes

done

...the problem comes when I try to access elements of the dynamically created arrays...eg.

print ${$name[*]}

...errors with :-

./admins[32]: ${$name[*]}: 0403-011 The specified substitution is not valid for this command.

...I have tried a number of variants on this ( print ${name[*]}, print ${\$name[*]} ) but always get the same error


any help much appreciated

Cheers
Reply With Quote
  #2 (permalink)  
Old 08-31-07, 11:49
aigles aigles is offline
Registered User
 
Join Date: Jan 2004
Location: Bordeaux, France
Posts: 319
Try :
Code:
eval print \${$name[*]}
__________________
Jean-Pierre.
Reply With Quote
  #3 (permalink)  
Old 09-03-07, 04:16
gendokai gendokai is offline
Registered User
 
Join Date: Aug 2007
Posts: 2
Doh! How simple.

Thank you, it worked a treat
Reply With Quote
Reply

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On