1 Reply Latest reply on Nov 14, 2014 12:44 PM by Bill Robinson

    NSH Script help

      Hi guys,

       

      below is the script which i am using to set the property of a server under one server smart group and i am not sure what i am doing wrong,

       

      Server smart group name is "All customer_name Servers -- BLAdmin only" and the path is correct.

      ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------

      GROUP="/GLOBAL/Customer/EU/All customer_name Servers -- BLAdmin only"

       

       

      SERVER_LIST=`blcli Server listServersInGroup $GROUP`

       

       

      for servername in $SERVER_LIST

       

       

      do

       

       

      blcli Server setPropertyValueByName $servername is_value 24

       

       

      done

       

      ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------

       

      i get the below error when i run the nsh script job.

       

      Unknown command : name space = 'Server', command = 'listServersInGroup'.com.bladelogic.om.infra.cli.factory.CommandNotFoundException: Found command 'Server.listServersInGroup' but with mismatching arguments. : java.lang.IllegalArgumentException: Wrong number of arguments provided to method : listServersInGroup expected : 1 received : 7

       

       

      any help is appriciated.

        • 1. Re: NSH Script help
          Bill Robinson

          the problem is that your group has spaces in it and you are not handling that properly when you pass it to the blcli so instead of 1 input it's getting 7.. also, there's a couple better ways to do this:

           

          --

          GROUP="/GLOBAL/Customer/EU/All customer_name Servers -- BLAdmin only"

          blcli_execute Server listServersInGroup "${GROUP}"

          blcli_storeenv SERVER_LIST

          for servername in ${SERVER_LIST}

                do

                blcli_execute Server setPropertyValueByName
          ${servername}" "is_value" "24"

          done

           

          ---

          alternatively, this might be faster:

           

           

           

          GROUP="/GLOBAL/Customer/EU/All customer_name Servers -- BLAdmin only"

          blcli_execute Server listServersInGroup "${GROUP}"

          blcli_storeenv SERVER_LIST

          echo "${SERVER_LIST}" | awk '{print $1",is_value,24"}' > $$.tmp

          blcli_execute Server bulkSetServerPropertyValues $(pwd) $$.tmp