2 Replies Latest reply on Aug 19, 2019 4:46 AM by Mike Poole

    NSH Concatenate Strings - overwriting

    Mike Poole
      Share This:

      Probably a simple answer but I'm struggling with this one.

       

      I'm trying to automatically create a set of Patch Catalog SmartGroups using BLCLI (easy enough).

       

      I need to create a condition for each Smart Group which basically says " Hotfixes Between". I have a file with a list of dates in it which I can read ok (into a variable $patchtuesday), but I can see that the Dates Between variable has to be in the format :

       

      “[MM/dd/yyyy hh:mm:ss-MM/dd/yyyy hh:mm:ss]”

       

      So my string needs to be something like "[$patchtuesday 00:00:00-$patchtuesday 23:59:00]"

       

      I'm trying to build this string variable but it keeps getting overwritten.

       

      echo $patchtuesday

      2019/01/08

      daterange="[$patchtuesday"

      echo $daterange

      [2019/01/08

       

      However....

       

      daterange="[$patchtuesday 00:00:00"

      echo $daterange

      00:00:0008

       

      or

       

      daterange="[$patchtuesday 00:00:00-$patchtuesday 23:59:00"

      echo $daterange

      23:59:00-2019/01/08

       

      Where am I going wrong ?

        • 1. Re: NSH Concatenate Strings - overwriting
          Bill Robinson

          what version/os are you on here:

          % daterange="[$patchtuesday 00:00:0008"

          % echo $daterange                     

          [2019/01/08 00:00:0008

          % daterange="[$patchtuesday 00:00:00-$patchtuesday 23:59:00"

          % echo $daterange                                          

          [2019/01/08 00:00:00-2019/01/08 23:59:00

          % version

          TrueSight Server Automation RSCD Agent 8.9.04.200 (Release) [Jan 22 2019 14:57:35]

          (C) Copyright 1996-2019 Bladelogic, Inc.

          (C) Copyright 2014-2019 BMC Software, Inc.

          TrueSight Server Automation Network Shell 8.9.04.200 (Release) [Jan 22 2019 14:57:35]

          (C) Copyright 1996-2019 Bladelogic, Inc.

          (C) Copyright 2014-2019 BMC Software, Inc.

          • 2. Re: NSH Concatenate Strings - overwriting
            Mike Poole

            Hi Bill,

             

            I managed to sort this.

             

            It appears that when I read from the file and get the date into the "patchtuesday" variable - it pulls in a hidden carriage return so I had to add the following line:

             

            pp=$(echo "$patchtuesday" | tr -d '\r')