4 Replies Latest reply on Mar 21, 2013 10:29 AM by Clement BARRET

    blcli_storeenv array of strings including spaces

      right now I have a small bit of script that looks something like this:

      _____________________________________________________________________

                blcli_execute JobGroup findAllGroupsByParentGroupName "/groupname"
                blcli_storeenv "childGroupList"


                for items in $childGroupList
                do


                blcli_execute JobGroup applyAclPolicy "/groupname/" items "ACLPolicy"

                done

      ______________________________________________________________________

       

      what I want to is get all child group names from the parent group name and then apply the ACL Policy to all of the child groups.  The problem I am having is that when I run the 'for loop', its separates items by spaces (i.e. "Test 3" because two different items,  "Test" & "3", when it should only be one item).  Is there a way I can run the code so that the array of strings keeps the spaces in the name of the child groups instead of separating by the spaces.

        • 1. Re: blcli_storeenv array of strings including spaces
          Siddu angadi

          Hi Alexander,

           

          Why do not use below command?

           

          Group bulkApplyBlAclPolicyByGroup

           

          Thanks

          Siddu

          • 2. Re: blcli_storeenv array of strings including spaces

            Did not know that was a command.  Thank you very much for you help, that was perfect

             

            Cheers,

            Alex

            • 3. Re: blcli_storeenv array of strings including spaces
              Bill Robinson

              also - if you have spaces in the object names i think you can do like this:

               

               

              FOO="stuff wth spaces"

               

              while read blah

              do

              echo $blah

              done <<< $FOO

              1 of 1 people found this helpful
              • 4. Re: blcli_storeenv array of strings including spaces
                Clement BARRET

                Hi,

                 

                Here is a good way to iterate trough a list of items even if they use spaces :

                 

                 

                % blcli_execute JobGroup findAllGroupsByParentGroupName "/"

                00 - Views

                01 - Administration

                10 - Audit

                BL_Administration

                TEST

                Software

                Server_Configuration

                Configuration

                Project

                05 - Inventory

                99 - Workspace by role

                Script-Tools

                Airbus

                Patch Analysis Jobs

                08 - Patch Management

                04 - Ad-Hoc administration

                06 - Compliance management

                02 - Packaging technique

                System Post-Configuration

                09 - Provisioning

                03 - Software-Configuration Packages

                PreProvisionning

                07 - Customer

                11 - Pastel

                13 - Scheduling jobs

                12 - GENERES

                tools

                 

                 

                % blcli_storeenv GROUPLIST

                 

                % for g in ${(f)GROUPLIST}; do echo "## My group is ${(qq)g}"; done

                ## My group is '00 - Views'

                ## My group is '01 - Administration'

                ## My group is '10 - Audit'

                ## My group is 'BL_Administration'

                ## My group is 'TEST'

                ## My group is 'Software'

                ## My group is 'Server_Configuration'

                ## My group is 'Configuration'

                ## My group is 'Project'

                ## My group is '05 - Inventory'

                ## My group is '99 - Workspace by role'

                ## My group is 'Script-Tools'

                ## My group is 'Airbus'

                ## My group is 'Patch Analysis Jobs'

                ## My group is '08 - Patch Management'

                ## My group is '04 - Ad-Hoc administration'

                ## My group is '06 - Compliance management'

                ## My group is '02 - Packaging technique'

                ## My group is 'System Post-Configuration'

                ## My group is '09 - Provisioning'

                ## My group is '03 - Software-Configuration Packages'

                ## My group is 'PreProvisionning'

                ## My group is '07 - Customer'

                ## My group is '11 - Pastel'

                ## My group is '13 - Scheduling jobs'

                ## My group is '12 - GENERES'

                ## My group is 'tools'

                 

                Once again, we use "PARAMETER EXPANSION" abilities of zsh (nsh) to split the results with "\n" so the array returned will include spaces in the items (the standard word split is using IFS which is by default "space tab newline and NUL" (' \t\n\0').

                 

                You also could just modify IFS and use a read.

                 

                % IFS=$'\n';

                 

                 

                % while read g; do echo "My group is ${(qq)g}"; done <<< "$GROUPLIST"

                My group is '00 - Views'

                My group is '01 - Administration'

                My group is '10 - Audit'

                My group is 'BL_Administration'

                My group is 'TEST'

                My group is 'Software'

                My group is 'Server_Configuration'

                My group is 'Configuration'

                My group is 'Project'

                My group is '05 - Inventory'

                My group is '99 - Workspace by role'

                My group is 'Script-Tools'

                My group is 'Airbus'

                My group is 'Patch Analysis Jobs'

                My group is '08 - Patch Management'

                My group is '04 - Ad-Hoc administration'

                My group is '06 - Compliance management'

                My group is '02 - Packaging technique'

                My group is 'System Post-Configuration'

                My group is '09 - Provisioning'

                My group is '03 - Software-Configuration Packages'

                My group is 'PreProvisionning'

                My group is '07 - Customer'

                My group is '11 - Pastel'

                My group is '13 - Scheduling jobs'

                My group is '12 - GENERES'

                My group is 'tools'

                My group is ''

                 

                or instead use a for loop

                 

                % for g in $GROUPLIST; do echo "My group is ${(qq)g}"; done

                My group is '00 - Views'

                My group is '01 - Administration'

                My group is '10 - Audit'

                My group is 'BL_Administration'

                My group is 'TEST'

                My group is 'Software'

                My group is 'Server_Configuration'

                My group is 'Configuration'

                My group is 'Project'

                My group is '05 - Inventory'

                My group is '99 - Workspace by role'

                My group is 'Script-Tools'

                My group is 'Airbus'

                My group is 'Patch Analysis Jobs'

                My group is '08 - Patch Management'

                My group is '04 - Ad-Hoc administration'

                My group is '06 - Compliance management'

                My group is '02 - Packaging technique'

                My group is 'System Post-Configuration'

                My group is '09 - Provisioning'

                My group is '03 - Software-Configuration Packages'

                My group is 'PreProvisionning'

                My group is '07 - Customer'

                My group is '11 - Pastel'

                My group is '13 - Scheduling jobs'

                My group is '12 - GENERES'

                My group is 'tools'

                 

                 

                NB: (f) is a shorthand for (ps:\n:), see "man zshall" chapter "PARAMETER EXPANSION" for more details.