blcli_storeenv and arrays - storing all server properties in an array

Version 2
    Share:|

    Courtesy of Alessandro Iacopetti:

     

    https://www.bladelogic.com/community/thread.jspa?messageID=21393&#21393

     

     

    --- initialization code stripped ---

     

    typeset -A props

     

    blcli_execute Server printAllProperties $SERVER >NUL

    blcli_storeenv PROPS

     

    ifs=$IFS

    IFS=$'\n'

    properties=( $( echo "$PROPS" | sed "s/ = /=/g") )

    IFS=$ifs

     

    for (( i=1 ; i <= ${#properties} ; i++ ))

    do

    line=$properties[$i]

    property=$line[(ws:=:)1]

    value=$line[(ws:=:)2]

     

    if [ $line

    then

    1. empty property

    value=""

    fi

    props[$property]=$value

    done

     

    -


     

    at the end of the loop the props associative array will contains all the properties indexed by name