dynamically setting an array

Hi Gurus,

How do I dynamically set up an array. Below is my code

if [[ $tsk_count -gt 0 ]]
  then

  set ecomm_task_limit = '${ecomm_srvr[$j]}'
fi

Here, I want to set values in the array "${ecomm_srvr[$j]}" into ecomm_task_limit upon each iteration. Finally I want to display all the values in the new array "ecomm_task_limit" after all the iterations are complete.

Thanks in advance

The following is the code snippet of an ksh array implementation,

#!/bin/ksh

set -A arr Hello world!! Iam Nagarajan Ganesan
set -A NewArray

let count=0
while [[ count -le 4 ]] ; do
   NewArray[${#NewArray[*]}]=${arr[$count]};
   print "NewArr[$count]= \c"
   print ${NewArray[$count]}
   ((count=count+1))
done
print "The New Array Has: \c"
print ${NewArray[*]}

OUTPUT:

$  /tmp/arr.ksh
NewArr[0]= Hello
NewArr[1]= world!!
NewArr[2]= Iam
NewArr[3]= Nagarajan
NewArr[4]= Ganesan
The New Array Has: Hello world!! Iam Nagarajan Ganesan

Hope this may help you. Please let us know if this doesn't work

Thanks
Nagarajan Ganesan

Nagarajan,

Thanks for your timely help. Your code worked as expected..

#!/bin/ksh
set -A proc $x
x=top| grep siebmtshmw |awk '{print $6}'|sed 's/\%//'
print $x
set -A proc $x
print ${proc[0]}
print ${proc[1]}
print ${proc[2]}
___
In nut shell Im trying to use top to get the desired process and then store them in a array and print them ..

You have not mentioned how many iterations of top should run,so this will keep blocking on that statement.
Also the assignment line is incorrect.

Try this approach,

  set -A proc $(top -n 5 | grep siebmtshmw |awk '{print $6}')
  echo ${proc[*]}

Thanks
Nagarajan G