4 Replies Latest reply on Jan 27, 2010 11:53 AM by Bill Robinson

    Why does this decom script not work?

      I have a simple script  as follows:

       

      #!/bin/nsh

       

      ##  NSH Script to decom servers from a text file

       

       

      #if [ $# -lt 1 ]; then

       

      #echo "Usage: 1 required arguement \nRequired:  [Server Name]

       

      #\n

       

      #    example1:  decom_server.nsh \"isswebapp02\"  \n"

       

      #exit 1

       

      #fi

       

       

      #Profile=$1

       

      #Set sign on type

       

      blcli_setoption authType BLSSO

       

      #Set authentication profile

       

      blcli_setoption serviceProfileName Production

       

      #Set the role of RBAC Profile my BladeLogic user runs under

       

      blcli_setoption roleName BLAdmins

       

      #Connect to blcli

       

      blcli_connect

       

      #serverName=$1

       

      SERVER_LIST=`cat decom_list.txt`

       

      blcli_storeenv SERVER_LIST

       

      for serverName in ${SERVER_LIST[@]}

       

      do

       

      #echo "$serverName"

       

      blcli_execute Server decommissionServer "$serverName"

       

      done

       

      I get the following results:

       

      No result has been created yet
      not foundecution failed. com.bladelogic.mfw.util.NotFoundException: device ABCDSSAPP02
      not foundecution failed. com.bladelogic.mfw.util.NotFoundException: device ABCLCWEB01
      not foundecution failed. com.bladelogic.mfw.util.NotFoundException: device ABCTVENV01
      not foundecution failed. com.bladelogic.mfw.util.NotFoundException: device ABCTVENV02
      not foundecution failed. com.bladelogic.mfw.util.NotFoundException: device CSREGBAR13
      not foundecution failed. com.bladelogic.mfw.util.NotFoundException: device CSREGBAR14
      not foundecution failed. com.bladelogic.mfw.util.NotFoundException: device CSREGBAR15
      not foundecution failed. com.bladelogic.mfw.util.NotFoundException: device CSREGBAR16
      not foundecution failed. com.bladelogic.mfw.util.NotFoundException: device CSREGBAR17
      not foundecution failed. com.bladelogic.mfw.util.NotFoundException: device CSRKMAPP01
      not foundecution failed. com.bladelogic.mfw.util.NotFoundException: device CSRKMAPP02
      not foundecution failed. com.bladelogic.mfw.util.NotFoundException: device DOLADMIN03
      not foundecution failed. com.bladelogic.mfw.util.NotFoundException: device DOLBABWEB05VM
      not foundecution failed. com.bladelogic.mfw.util.NotFoundException: device DOLDISBAR01
      not foundecution failed. com.bladelogic.mfw.util.NotFoundException: device DOLDISBAR08
      not foundecution failed. com.bladelogic.mfw.util.NotFoundException: device DOLECLIPSEAPP01
      not foundecution failed. com.bladelogic.mfw.util.NotFoundException: device DOLECLIPSEAPP02
      not foundecution failed. com.bladelogic.mfw.util.NotFoundException: device DOLLOWSRCVM01

        • 1. Re: Why does this decom script not work?

          Looks like the server names may be getting some extra white space at the end of the output. Run the server names through a trim function to see if that helps. Also, if you do blcli_execute Server decommissionServer ABCDSSAPP02 does it work? Thirdly, You shouldn't need quotes around your servername as they would never be allowed to have spaces.

          • 2. Re: Why does this decom script not work?
            Bill Robinson

            blcli_storeenv is only for storing the result of a blcli command, which this:

             

            SERVER_LIST=`cat decom_list.txt`

             

            blcli_storeenv SERVER_LIST

             

            is not.

             

            and you can probably make this:

             

            for serverName in ${SERVER_LIST[@]}

             

            to just this:

             

            for serverName in ${SERVER_LIST}

             

            you may want to add a line

             

            serverName=`echo $serverName | tr -d '[:cntrl:]'`

             

            to strip any control characters off of the server name before passing it to the blcli decomission command.

            • 3. Re: Why does this decom script not work?

              Thanks, gents.  your suggestions worked, final version is below.  Question, would messing around with the IFS possibly prevented the need to strip out characters in the servername?

               

              #!/bin/nsh
              ##  NSH Script to decom servers

               

              #if [ $# -lt 1 ]; then
              #echo "Usage: 1 required arguement \nRequired:  [Server Name]
              #\n
              #    example1:  decom_server.nsh \"isswebapp02\"  \n"
              #exit 1
              #fi

               


              #Profile=$1

               

              #Set sign on type
              blcli_setoption authType BLSSO
              #Set authentication profile
              blcli_setoption serviceProfileName Production
              #Set the role of RBAC Profile my BladeLogic user runs under: ex:  BLAdmins, SOC, etc.
              blcli_setoption roleName BLAdmins

               


              #Connect to blcli
              blcli_connect

               


              #serverName=$1

               


              SERVER_LIST=`cat decom_list.txt`

               


              for serverName in ${SERVER_LIST}
              do
              #echo "$serverName"
              serverName=`echo $serverName | tr -d '[:cntrl:]'`
              blcli_execute Server decommissionServer $serverName
              done

              • 4. Re: Why does this decom script not work?

                Meh, possibly. Though if your inpurt can be an unpredictable format, it is best to run it through some kind of cleanup routine first like Bill provided/