10 Replies Latest reply on Dec 7, 2018 12:51 PM by Bill Robinson

    Unpredicted behaviour in NSH script job

    Tymen Abels

      Dear community,

       

      Recently I am programming a NSH script that can automate all of our patch scedules (88 to be precise).

      We do have 4 different environments to fullfill our DTAP strategy. (development, test, acceptance, production)

       

      The basics ot the script is as following.

      First we calculate the second tuesday which is used by Microsoft to announce its new patches.

      once that is finished, we enumerate a custom property class called "CIS_MW" in which all of our maintenance windows reside as an instance.

      In that instance, the maintenance window start day and start hour are defined as an integer plus the offset hours when the server needs to be analysed and offset when patches willbe prestaged which are also integers.

       

      For everyone of the defined maintenance windows, we also create smartgroups and once they don't exist, the group will be created by this script.

      These groups are used as targets for the actual patchjob.

      this patchjob is looked up, and once it not exists, it will be created from a template job.

      Next the advanced deployjob options are set to a template job and then copied towards the patchjob affected.

      Last, the one time schedule to the patchjob is set so on the timestamp when the analysis is needed, the schedule will trigger the patchjob

       

      This works neatly in our Development and Test environment, but in our Acceptance environment I hit some unpredicted behaviour.

       

      MW_CUSTOM_PROP_CLASS="Class://SystemObject/CIS_MW"

       

      #calls function to calculate second tuesday

      calculate_base_date

       

      echo "search MW instances"

      for MW in `blcli_execute PropertyClass listAllInstanceNames "$MW_CUSTOM_PROP_CLASS"` ; do

           echo "$MW"

           blcli_execute PropertyInstance isInstanceDeprecated "$MW"

           blcli_storeenv DEPRECATED

           ....... do some more stuff....

       

      This peace of code looks up the "$MW_CUSTOM_PROP_CLASS" instances which all of our maintenance windows are in. and for each one do some stuff.

      once I run this command without for loop. I got neat results. All of my defined instances will be printed out towards the console.

      but inside this forloop, no results are retrieved and it immediately ends the for-loop without doing one thing. (the echo "$MW" codeline is never triggered.)

       

      Can someone help me solve this issue?

        • 1. Re: Unpredicted behaviour in NSH script job
          Davorin Stevanovic

          could you call command earlier and make sure it is run properly and that data is filled without any issues:

           

          blcli_execute PropertyClass listAllInstanceNames "$MW_CUSTOM_PROP_CLASS"

          blcli_storelocal myVariable

           

          for MW in $myVariable ; do

           

           

          with this setup you can make sure blcli command is running properly and filling the variable with the data or you can use additional checks if command fails. Try to setuup set-x and see logs to verify if flow is correct.

          • 2. Re: Unpredicted behaviour in NSH script job
            Bill Robinson

            right - when you do this:

            `blcli_execute PropertyClass listAllInstanceNames "$MW_CUSTOM_PROP_CLASS"`

             

            that spawns off a child process which will likely not inherite the authentication you have setup in the parent and it's spawning a new jvm which defeats the purpose of the embeded blcli.

             

            so i would actually do:

            blcli_execute PropertyClass listAllInstanceNames "$MW_CUSTOM_PROP_CLASS"

            blcli_storelocal myVariable

            while read MW ; do

                 echo "$MW"

                 blcli_execute PropertyInstance isInstanceDeprecated "$MW"

                 blcli_storeenv DEPRECATED

            done <<< "${myVariable}"

            • 3. Re: Unpredicted behaviour in NSH script job
              Tymen Abels

              Hello and thanks for this quick response.

               

              I have now modified the code using  the blcli_storelocal option

               

              echo "search MW instances"

              blcli_execute PropertyClass listAllInstanceNames "$MW_CUSTOM_PROP_CLASS"

              blcli_storelocal allMW

              for MW in "$allMW" ; do

                   echo "$MW"

                   blcli_execute PropertyInstance isInstanceDeprecated "$MW"

                   blcli_storeenv DEPRECATED

                        ... do stuff ....

               

              Now it seems that somehow an instances is marked depricated.

              This is the output of the line 'isInstanceDepricated'

              And $MW seems to be empty.

               

              Somehow it seems that enumeration of the result out of blcli_execute PropertyClass listAllInstanceNames "$MW_CUSTOM_PROP_CLASS" does not work that properly for me.

               

              any suggestions what I can do to troubleshoot this any further?

              • 4. Re: Unpredicted behaviour in NSH script job
                Bill Robinson

                because this:

                for MW in "$allMW" ; do

                is probably not reading each 'line' of input, where as the example i sent should.

                • 5. Re: Unpredicted behaviour in NSH script job
                  Tymen Abels

                  Hi Bill,

                   

                  I have now executed this line

                   

                  calculate_base_date

                  echo "search MW instances"

                  blcli_execute PropertyClass listAllInstanceNames "$MW_CUSTOM_PROP_CLASS"

                  blcli_storelocal allMW

                  while read MW ; do

                       echo "$MW"

                       blcli_execute PropertyInstance isInstanceDeprecated "$MW" >> /dev/null

                       blcli_storeenv DEPRECATED

                   

                       .... do stuff ...

                   

                  the result is the same as before, immedately it reached the end of the forloop. So obviously it is not reaching the instances.

                  I do believe this is not a NSH script error but some funny thing within TSA which I cannot pinpoint in one or another way.

                  Also since this piece of code works on 2 identical other seperate environments without a problem.

                   

                  What should be the next place to search?

                  • 6. Re: Unpredicted behaviour in NSH script job
                    Bill Robinson

                    then step through each step:

                     

                    blapp893# blcli_execute PropertyClass listAllInstanceNames "Class://SystemObject/Remediation Properties"

                    Class://SystemObject/Remediation Properties/default

                    Class://SystemObject/Remediation Properties/red7-893.example.com_Instance

                     

                     

                    blapp893# blcli_storelocal instances

                    blapp893# while read i

                    while> do

                    while> echo "**${i}**"

                    while> blcli_execute PropertyInstance isInstanceDeprecated "${i}"

                    while> blcli_storelocal isDep

                    while> echo "*** ${i}: ${isDep}"

                    while> done <<< "${instances}"

                    **Class://SystemObject/Remediation Properties/default**

                    false

                    *** Class://SystemObject/Remediation Properties/default: false

                    **Class://SystemObject/Remediation Properties/red7-893.example.com_Instance**

                    false

                    *** Class://SystemObject/Remediation Properties/red7-893.example.com_Instance: false

                    ****

                    Command execution failed. com.bladelogic.om.infra.mfw.util.BlException: Instance  specified in incorrect syntax

                    Cannot store a failed command result

                    *** : false

                     

                    the error at the end can be handled by trimming the last new line off 'instances'.

                    • 7. Re: Unpredicted behaviour in NSH script job
                      Tymen Abels

                      Hi,

                       

                      I have done the seperate steps within a nsh shell but with no results. the same unpredictive behaviour is seen.

                      Also, I have implemented the original script in our production TSA environment and guess what ? it works like a charm there.

                      So, to be precise, I can rule out the script as possible fault.

                       

                      It has to do something within out acceptance tsa environment which is causing this misbehaviour.

                      what should be a good way to have this issue sorted out ? maybe raise a supportcase ?

                       

                      thanks for all the help so far!

                      • 8. Re: Unpredicted behaviour in NSH script job
                        Bill Robinson

                        can you share the script that you are using that is having problems ?

                        • 9. Re: Unpredicted behaviour in NSH script job
                          Tymen Abels

                          # To-Do:

                          # - use Parameters

                          # - more advanced error handling

                           

                           

                          ### Dynamic Parameters

                          COMMIT_OFFSET_HOURS=0

                          OS_LIST="Windows"

                           

                           

                          ### Static Parameters CIS

                          UTIL_JOB_NAME="_DJ_SEC_WIN_PatchDefinition_v1.0"

                          UTIL_JOB_FOLDER="/Patching Jobs/Templates"

                          PATCH_JOB_FOLDER="/Patching jobs"

                          REMMEDIATION_DEPOT_FOLDER="/Patching/Windows/Package"

                          REMMEDIATION_JOB_FOLDER="/Patching Jobs/Windows/Batch"

                          MW_CUSTOM_PROP_CLASS="Class://SystemObject/CIS__MW"

                          SERVER_GROUP_MW1="/Lifecycle Management/First Window"

                          SERVER_GROUP_MW2="/Lifecycle Management/Second Window"

                          PATCH_JOB_TEMPLATE_FOLDER="/Patching Jobs/Templates"

                           

                           

                          calculate_base_date() {

                           

                          #Calculate second Tuesday of current month:

                          TODAY_AS_INT=`blexpr 'show_date (get_date(), "%d")' | tr -d '[:cntrl:]'`

                          TODAY_HOURS=`blexpr 'show_date (get_date(), "%H")' | tr -d '[:cntrl:]'`

                          TODAY_MIN=`blexpr 'show_date (get_date(), "%M")' | tr -d '[:cntrl:]'`

                          TODAY_HOURS_EPOCH_OFFSET=$(( $TODAY_HOURS*60*60 ))

                          TODAY_EPOCH_OFFSET=$(( $TODAY_MIN*60+$TODAY_HOURS_EPOCH_OFFSET ))

                           

                          if [ $TODAY_AS_INT = 01 ]

                          then

                              P=0

                              P=$(( $P + $TODAY_EPOCH_OFFSET ))

                              FIRST_DAY_OF_MONTH=`blexpr 'show_date (get_date(), "%Y-%m-%d")' | tr -d '[:cntrl:]'`

                              FIRST_DAY_OF_MONTH_EPOCH=`blexpr 'get_date()-'$P'' | tr -d '[:cntrl:]'`

                          else

                              P=0

                              TODAY_AS_INT=`blexpr 'show_date (get_date(), "%d")' | tr -d '[:cntrl:]'`

                              while [ $TODAY_AS_INT != 01 ]

                              do

                                  P=$(( $P + 86400 ))

                                  TODAY_AS_INT=`blexpr 'show_date (get_date()-'$P', "%d")' | tr -d '[:cntrl:]'`

                              done

                              P=$(( $P + $TODAY_EPOCH_OFFSET ))

                              # set 1st day of current calendar month property in both YYYY-MM-DD format and EPOCH

                              FIRST_DAY_OF_MONTH=`blexpr 'show_date (get_date()-'$P', "%Y-%m-%d")' | tr -d '[:cntrl:]'`

                              FIRST_DAY_OF_MONTH_EPOCH=`blexpr 'get_date()-'$P'' | tr -d '[:cntrl:]'`

                           

                          fi

                           

                          echo "First Day of the month: $FIRST_DAY_OF_MONTH"

                           

                          z=0

                          CURRENT_DOW=`blexpr 'show_date ('$FIRST_DAY_OF_MONTH_EPOCH',"%A")' | tr -d '[:cntrl:]'`

                          echo "Day of the week (first day): $CURRENT_DOW"

                           

                          if [ "$CURRENT_DOW" = "Monday" ]; then

                              SECOND_TUESDAY_EPOCH=$(( $FIRST_DAY_OF_MONTH_EPOCH+86400*8 ))

                          elif  [ "$CURRENT_DOW" = "Tuesday" ]; then

                              SECOND_TUESDAY_EPOCH=$(( $FIRST_DAY_OF_MONTH_EPOCH+86400*7 ))

                          elif  [ "$CURRENT_DOW" = "Wednesday" ]; then

                              SECOND_TUESDAY_EPOCH=$(( $FIRST_DAY_OF_MONTH_EPOCH+86400*13 ))

                          elif  [ "$CURRENT_DOW" = "Thursday" ]; then

                              SECOND_TUESDAY_EPOCH=$(( $FIRST_DAY_OF_MONTH_EPOCH+86400*12 ))

                          elif  [ "$CURRENT_DOW" = "Friday" ]; then

                              SECOND_TUESDAY_EPOCH=$(( $FIRST_DAY_OF_MONTH_EPOCH+86400*11 ))

                          elif  [ "$CURRENT_DOW" = "Saturday" ]; then

                              SECOND_TUESDAY_EPOCH=$(( $FIRST_DAY_OF_MONTH_EPOCH+86400*10 ))

                          elif  [ "$CURRENT_DOW" = "Sunday" ]; then

                              SECOND_TUESDAY_EPOCH=$(( $FIRST_DAY_OF_MONTH_EPOCH+86400*9 ))

                          fi

                           

                          SECOND_TUESDAY=`blexpr "show_date ($SECOND_TUESDAY_EPOCH, '%Y-%m-%d')" | tr -d '[:cntrl:]'`

                          echo "Second Tuesday: $SECOND_TUESDAY"

                          }

                           

                           

                          function set_patch_schedule() {

                          OPSYS=$1

                          MAINTEANCE_WINDOW=$2

                           

                          ### gather patchjob dbKey

                          blcli_execute PatchingJob getDBKeyByGroupAndName "$PATCH_JOB_FOLDER/$OPSYS" "_SPD_SEC_WIN_Patching_""$MW_NAME" >> /dev/null

                          blcli_storeenv PATCH_JOB_KEY

                           

                          echo "Applying settings to remediation jobs"

                          ### set advanced deployjob options from template job to the real patchjob

                          blcli_execute PatchingJob setRemediationWithDeployOptions "$PATCH_JOB_KEY" "$MAINTENANCE_WINDOW" "$REMMEDIATION_DEPOT_FOLDER" "$REMMEDIATION_JOB_FOLDER" "$UTIL_JOB_KEY" >> /dev/null

                          blcli_storeenv PATCH_JOB_KEY

                           

                          echo "Removing old schedules from patch job"

                          ### remove any existing schedule from the patch job

                          blcli_execute Job removeAllSchedules "$PATCH_JOB_KEY" >> /dev/null

                          blcli_storeenv PATCH_JOB_KEY

                           

                          echo "Adding one time schedule for patch analysis"

                          ### set analyse time as onetime schedule

                          blcli_execute Job addOneTimeSchedule "$PATCH_JOB_KEY" "$ANALYSE_STAMP" >> /dev/null

                          blcli_storeenv PATCH_JOB_KEY

                           

                          #if [ "$OS" = "Iets"] ; then

                          #echo "adapt maintenance execution task"

                          #blcli_execute ExecutionTask getDBKeyByGroupAndName "$PATCH_JOB_FOLDER/Monitoring" "MaintenanceMode-""$MW_NAME"

                          #blcli_storeenv EXECUTION_TASK_KEY

                           

                          #echo "set one time schedule"

                          #blcli_execute ExecutionTask addOneTimeSchedule "$EXECUTION_TASK_KEY" "$MAINTENANCE_STAMP" >> /dev/null

                          #blcli_storeenv EXECUTION_TASK_KEY

                          #fi

                          }

                           

                           

                          function check_smart_groups () {

                          OPSYS=$1

                          MAINTENANCE_WINDOW=$2

                           

                          ### find smartgroup for first maintenance window by maintenance window name

                          blcli_execute SmartServerGroup findGroupByQualifiedName  "$SERVER_GROUP_MW1/$OPSYS/$MAINTENANCE_WINDOW" >> /dev/null

                          if [ $? -ne 0 ] ; then

                          echo "Primary Smart Group for MW $MAINTENANCE_WINDOW not found, creating it."

                          # smart group creation

                          blcli_execute SmartServerGroup createGroup "$SERVER_GROUP_MW1/$OPSYS" "$MAINTENANCE_WINDOW" "" MAINTENANCE_WINDOW_1 "equals" "$MAINTENANCE_WINDOW" >> /dev/null

                          blcli_execute SmartServerGroup addCondition "$SERVER_GROUP_MW1/$OPSYS/$MAINTENANCE_WINDOW" "AGENT_STATUS" "equals" "agent is alive" >> /dev/null

                          case $OPSYS in

                          "Windows") echo "OS is Windows"

                          blcli_execute SmartServerGroup addCondition "$SERVER_GROUP_MW1/$OPSYS/$MAINTENANCE_WINDOW" "OS" "equals" "Windows" >> /dev/null

                          ;;

                          "RHEL5") echo "OS is RHEL5"

                          blcli_execute SmartServerGroup addCondition "$SERVER_GROUP_MW1/$OPSYS/$MAINTENANCE_WINDOW" "OS" "equals" "Linux" >> /dev/null

                          blcli_execute SmartServerGroup addCondition "$SERVER_GROUP_MW1/$OPSYS/$MAINTENANCE_WINDOW" "OS_VERSION" "starts with" "Red Hat 5." >> /dev/null

                          ;;

                          "RHEL6") echo "OS is RHEL6"

                          blcli_execute SmartServerGroup addCondition "$SERVER_GROUP_MW1/$OPSYS/$MAINTENANCE_WINDOW" "OS" "equals" "Linux" >> /dev/null

                          blcli_execute SmartServerGroup addCondition "$SERVER_GROUP_MW1/$OPSYS/$MAINTENANCE_WINDOW" "OS_VERSION" "starts with" "Red Hat 6." >> /dev/null

                          ;;

                          esac

                          blcli_execute SmartServerGroup setMatchAll "$SERVER_GROUP_MW1/$OPSYS/$MAINTENANCE_WINDOW" true

                          else

                          echo "Primary Smart Group for MW $MAINTENANCE_WINDOW found"

                          fi

                          ### find smartgroup for second maintenance window by maintenance name

                          blcli_execute SmartServerGroup findGroupByQualifiedName  "$SERVER_GROUP_MW2/$OPSYS/$MAINTENANCE_WINDOW" >> /dev/null

                          if [ $? -ne 0 ] ; then

                          echo "Secondary Smart Group for MW $MAINTENANCE_WINDOW not found, creating it."

                          # smart group creation

                          blcli_execute SmartServerGroup createGroup "$SERVER_GROUP_MW2/$OPSYS" "$MAINTENANCE_WINDOW" "" MAINTENANCE_WINDOW_2 "equals" "$MAINTENANCE_WINDOW" >> /dev/null

                          blcli_execute SmartServerGroup addCondition "$SERVER_GROUP_MW2/$OPSYS/$MAINTENANCE_WINDOW" "AGENT_STATUS" "equals" "agent is alive" >> /dev/null

                          case $OPSYS in

                          "Windows") echo "OS is Windows"

                          blcli_execute SmartServerGroup addCondition "$SERVER_GROUP_MW2/$OPSYS/$MAINTENANCE_WINDOW" "OS" "equals" "Windows" >> /dev/null

                          ;;

                          "RHEL5") echo "OS is RHEL5"

                          blcli_execute SmartServerGroup addCondition "$SERVER_GROUP_MW2/$OPSYS/$MAINTENANCE_WINDOW" "OS" "equals" "Linux" >> /dev/null

                          blcli_execute SmartServerGroup addCondition "$SERVER_GROUP_MW2/$OPSYS/$MAINTENANCE_WINDOW" "OS_VERSION" "starts with" "Red Hat ES 5." >> /dev/null

                          ;;

                          "RHEL6") echo "OS is RHEL6"

                          blcli_execute SmartServerGroup addCondition "$SERVER_GROUP_MW2/$OPSYS/$MAINTENANCE_WINDOW" "OS" "equals" "Linux" >> /dev/null

                          blcli_execute SmartServerGroup addCondition "$SERVER_GROUP_MW2/$OPSYS/$MAINTENANCE_WINDOW" "OS_VERSION" "starts with" "Red Hat ES 6." >> /dev/null

                          ;;

                          esac

                          blcli_execute SmartServerGroup setMatchAll "$SERVER_GROUP_MW2/$OPSYS/$MAINTENANCE_WINDOW" true

                          else

                          echo "Secondary Smart Group for MW $MAINTENANCE_WINDOW found"

                          fi

                          }

                           

                           

                          function check_patch_jobs() {

                          OPSYS=$1

                          MAINTENANCE_WINDOW=$2

                          ### search for patchjob db key

                          blcli_execute PatchingJob getDBKeyByGroupAndName "$PATCH_JOB_FOLDER/$OPSYS" "_SPD_SEC_WIN_Patching_""$MAINTENANCE_WINDOW" >> /dev/null

                          if [ $? -ne 0 ] ; then

                          echo "Patch Job $OPSYS for MW $MAINTENANCE_WINDOW missing."

                          ### create new job from template job

                          blcli_execute PatchingJob getDBKeyByGroupAndName "$PATCH_JOB_TEMPLATE_FOLDER" $OPSYS"PatchTemplateJob" >> /dev/null

                          blcli_storeenv TEMP_JOB

                          blcli_execute Job copyJob $TEMP_JOB "$PATCH_JOB_FOLDER/$OPSYS" "_SPD_SEC_WIN_Patching_""$MAINTENANCE_WINDOW" >> /dev/null

                          blcli_storeenv NEW_JOB

                          blcli_execute Job addTargetGroups $NEW_JOB "$SERVER_GROUP_MW1/$OPSYS/$MAINTENANCE_WINDOW","$SERVER_GROUP_MW2/$OPSYS/$MAINTENANCE_WINDOW" >> /dev/null

                          echo "Patch Job $OPSYS for MW $MAINTENANCE_WINDOW created."

                          else

                          echo "Patch Job for MW $MW_NAME found."

                          fi

                          }

                           

                           

                          #### Main Workflow

                           

                           

                          calculate_base_date

                          echo "search MW instances"

                          blcli_execute PropertyClass listAllInstanceNames "$MW_CUSTOM_PROP_CLASS"

                          blcli_storelocal allMW

                          while read MW ; do

                          echo "$MW"

                          blcli_execute PropertyInstance isInstanceDeprecated "$MW" >> /dev/null

                          blcli_storeenv DEPRECATED

                           

                          if [ "$DEPRECATED" = "false" ] ; then

                          # get name of MW

                          blcli_execute PropertyInstance getPropertyValue $MW NAME >> /dev/null

                          blcli_storeenv MW_NAME

                          echo "MW Name: $MW_NAME"

                          ## get details from MW instance

                          blcli_execute PropertyInstance getPropertyValue $MW MW_START_DAY >> /dev/null

                          blcli_storeenv MW_START_DAY

                          echo "Start day: $MW_START_DAY"

                          blcli_execute PropertyInstance getPropertyValue $MW MW_START_HOUR >> /dev/null

                          blcli_storeenv MW_START_HOUR

                          echo "Commit offset time: $MW_START_HOUR"

                          ## since not all windows will start analyse and stage at the same time, made them variable.

                          blcli_execute PropertyInstance getPropertyValue $MW MW_ANALYSE_OFFSET >> /dev/null

                          blcli_storeenv ANALYSE_OFFSET_HOURS

                          echo "Analyse offset time: $ANALYSE_OFFSET_HOURS"

                          blcli_execute PropertyInstance getPropertyValue $MW MW_STAGE_OFFSET >> /dev/null

                          blcli_storeenv SIMULATE_OFFSET_HOURS

                          echo "stage offset time: $SIMULATE_OFFSET_HOURS"

                           

                          ## Set all timestamps needed for patching.

                          ANALYSE_STAMP=`blexpr "show_date($SECOND_TUESDAY_EPOCH + 86400 * $MW_START_DAY + 3600 * ($MW_START_HOUR + $ANALYSE_OFFSET_HOURS),'%Y-%m-%d %H:%M:%S')"`

                          echo "Analyse Start Time is: $ANALYSE_STAMP"

                           

                          SIMULATE_STAMP=`blexpr "show_date($SECOND_TUESDAY_EPOCH + 86400 * $MW_START_DAY + 3600 * ($MW_START_HOUR + $SIMULATE_OFFSET_HOURS),'%Y-%m-%d %H:%M:%S')"`

                          echo "Stage Start Time for $MW_NAME is: $SIMULATE_STAMP"

                           

                          COMMIT_STAMP=`blexpr "show_date($SECOND_TUESDAY_EPOCH + 86400 * $MW_START_DAY + 3600 * ($MW_START_HOUR + $COMMIT_OFFSET_HOURS),'%Y-%m-%d %H:%M:%S')"`

                          echo "Commit Start Time for $MW_NAME is: $COMMIT_STAMP"

                           

                          #set starttime for execution task to 15 minutes upfront patching commit stamp

                          MAINTENANCE_STAMP=`blexpr "show_date($SECOND_TUESDAY_EPOCH + 86400 * $MW_START_DAY + 3600 * ($MW_START_HOUR + $COMMIT_OFFSET_HOURS) - 900,'%Y-%m-%d %H:%M:%S')"`

                          echo "Maintenance Start Time for $MW_NAME is: $MAINTENANCE_STAMP"

                           

                          blcli_execute DeployJob getDBKeyByGroupAndName "$UTIL_JOB_FOLDER" "$UTIL_JOB_NAME" >> /dev/null

                          blcli_storeenv UTIL_JOB_KEY

                           

                          ### set advanced deploy job options on the template job

                          blcli_execute DeployJob setAdvanceDeployJobPhaseScheduleByDBKey $UTIL_JOB_KEY NotScheduled "" AtTime "$SIMULATE_STAMP" AtTime "$COMMIT_STAMP" >> /dev/null

                          blcli_storeenv UTIL_JOB_KEY

                           

                          # for now only windows is affected.

                          for OS in $OS_LIST ; do

                          echo "OS: $OS"

                          check_smart_groups $OS $MW_NAME

                          check_patch_jobs $OS $MW_NAME

                          set_patch_schedule $OS $MW_NAME

                          done

                          else

                          echo "Instance $MW deprecated, skipping it!"

                          fi

                          done

                          • 10. Re: Unpredicted behaviour in NSH script job
                            Bill Robinson

                            well, one problem is you aren't reading in the variable of the list at the end of your loop:

                             

                            while read MW ; do

                            echo "$MW"

                            [..]

                            done <<< "${allMW}"

                             

                            that's likely why you are not getting into your loop.

                             

                            another problem i see is that you don't quote your variables.  anything w/ a space is going to cause problems in various places in your script.

                             

                            and if you want to not see stdout from the blcli calls, don't redirect like this:

                            blcli_execute PropertyInstance getPropertyValue $MW NAME >> /dev/null

                            instead, at the top of the script before any other blcli calls, put this:

                            blcli_setjvmoption -Dcom.bladelogic.cli.execute.quietmode.enabled=true