Hi, I'm quite new at unix and was wondering if anyone could help me with this.
I have 2 arrays:
eg. STAT[0]=online, STAT[1]=offline, STAT[2]=online
WWN[0]=xxxx1, WWN[1]=xxxx2, WWN[2]=xxxx3
I got these information from a script using fcinfo hba-port that runs through a loop.
Now, I want to store (concatenate) them into one variable, say OUTPUT, which will have some kind of format like
HBA at xxxx1 is online ;; HBA at xxxx2 is offline ;; HBA at xxxx3 is online ;;
The thing is, depending on the server, the number of HBA card varies. How should I go about doing it?
The section of the script that stores the values into the array is:
HBA_COUNT=`sudo fcinfo hba-port | grep -i state | awk 'END{print NR}'`
(( HBA_COUNT=$HBA_COUNT-1 ))
INDEX1=0
while [[ $INDEX1 -le $HBA_COUNT ]] ; do
HBA_STAT[$INDEX1]=`sudo fcinfo hba-port | grep -i 'state' | awk 'NR=='$INDEX1 | awk '{print $NF}'`
HBA_WWN[$INDEX1]=`sudo fcinfo hba-port | grep -i 'Port WWN' | awk 'NR=='$INDEX1 | awk '{print $NF}'`
(( INDEX1=$INDEX1+1 ))
done
Thanks in advance