Results 1 to 3 of 3
  1. #1
    Join Date
    Aug 2007
    Posts
    2

    Unanswered: 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

  2. #2
    Join Date
    Jan 2004
    Location
    Bordeaux, France
    Posts
    320
    Try :
    Code:
    eval print \${$name[*]}
    Jean-Pierre.

  3. #3
    Join Date
    Aug 2007
    Posts
    2
    Doh! How simple.

    Thank you, it worked a treat

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •