Hi,
The following test case populate an array named: array3.
Since array1 and array2 are equal in length and values array3 will remain empty.
#!/usr/bin/ksh
test() {
set -A array1 "A"
set -A array2 "A"
NUM_1=`echo ${#array1[*]}`
print "num elenemt in NUM_1 is ${NUM_1}"
i=1
for ELE2 in ${array2[*]}; do
Z=0
for ELE1 in ${array1[*]}; do
if [[ $ELE1 != $ELE2 ]]; then
let Z=$Z+1
if [[ $Z = $NUM_1 ]]; then
${array3}=$ELE2
let i=i+1
fi
fi
done
done
print "The array 3 contain : ${array3[*]}"
NUM_2=`echo ${#array3[*]}`
exit 0
}
while :
do
# clear
echo "----------------------------------------------"
echo " * * * * * * * test * * * * * * * "
echo "----------------------------------------------"
echo "[1] Test "
echo "[2] Exit/stop"
echo "----------------------------------------------"
echo -n "Enter your menu choice [1-10]:"
read yourch
case $yourch in
1) test ;;
2) exit 10
;;
*) echo "Opps!!! Please select choice 1,2"
echo "Press a key. . ."
;;
esac
done
Here are the results:
$ ./mytest.ksh
----------------------------------------------
* * * * * * * test * * * * * * *
----------------------------------------------
[1] Test
[2] Exit/stop
----------------------------------------------
Enter your menu choice [1-10]:1
num elenemt in NUM_1 is 1
The array 3 contain :
=====================================================
Now i took the same logic from this test and insreted it into another script.
This time i am getting an error regarding to array3.
I printed all the necessary information
Could you please tell me why i am getting an error in this case:
The relevant function is:
reset_initora_asm_diskgroups() {
print "Original DGs list: ${PreDistinctDGs[*]}"
print "Cloned DGs list: ${AfterDistinctDGs[*]}"
print "Num of element in original DGs list:${num_of_unique_dgs_pre_clone}"
print "Num of element in Cloned DGs list:${num_of_unique_dgs_after_clone}"
j=1
for ELE2 in ${AfterDistinctDGs[*]}; do
Z=0
for ELE1 in ${PreDistinctDGs[*]}; do
if [[ $ELE1 != $ELE2 ]]; then
let Z=$Z+1
if [[ $Z = $num_of_unique_dgs_pre_clone ]]; then
${array3[j]}=$ELE2
let j=j+1
fi
fi
done
done
print "j= ${j}"
print "The array3 contain : ${array3[*]}"
exit 0
}
Running the function raised the foollowing error:
Enter your menu choice [1-10]:6
Original DGs list: DSDWHDATA
Cloned DGs list: DSDWHDATA
Num of element in original DGs list:1
Num of element in Cloned DGs list:1
j= 1
./CloneASM.sh[478]: array3[*]: parameter not set
Thanks