4 Replies Latest reply on Mar 21, 2013 5:41 PM by Siddu angadi

    excel or CSV as input files

      I am trying use the command:

       

      blcli_execute BlPackage deleteBlPackageByGroupAndName $Group $Name

       

      The command line itself works fine.  I was just wondering if there is a way to use an xml file or csv file as a input.  Right now I have an excel file with all the package's name in one column and all the group's name for said packages in another column.  It is a very long list of packages and ideally I would like to run some sort loop that pulls in the all package names and package group seperately so I can go through the entire list using the command line above.

        • 1. Re: excel or CSV as input files
          Siddu angadi

          Create test.csv file and first column should have GroupName and 2nd column should have package Name.

           

          use Below code:

           

           

          ##########################################################################

           

          Lines=`cat test.csv`

           

          For Line in $Lines

          do

               echo $Line

           

               Group=`echo $Line | cut -d ',' -f1`

               Name=`echo $Line | cut -d ',' -f2`

           

               blcli_execute BlPackage deleteBlPackageByGroupAndName $Group $Name


          done

           

           

           

           

          ###########################################################################

          1 of 1 people found this helpful
          • 2. Re: excel or CSV as input files
            Bill Robinson

            if there are spaces in the file lines that's not going to work.

             

            you should do:

             

            while read Line

            do

                 echo $Line

             

                 Group=`echo $Line | cut -d ',' -f1`

                 Name=`echo $Line | cut -d ',' -f2`

             

                 blcli_execute BlPackage deleteBlPackageByGroupAndName $Group $Name


            done < test.csv

            1 of 1 people found this helpful
            • 3. Re: excel or CSV as input files

              I put that into the script but now I am getting the error:

               

              command execution failed. com.bladelogic.om.infra.mfw.util.BlException: Cannot find depot object by  in group : Engineering with type : BLPACKAGE

               

              I know that parentGroup and packageName are correct, because when I run the code without the loop -just hard coded the packages names and parentGroups into the script itself- it works.  I am only having problems when I run it with the loop.  And I am pretty sure the csv file is formatted correctly.  I am using windows' notebook to create the csv file, I dont know if that would be the problem though.

              • 4. Re: excel or CSV as input files
                Siddu angadi

                Hi,

                 

                It might be because of whitespace in the group name, so change the blcli_execute command to :

                 

                  blcli_execute BlPackage deleteBlPackageByGroupAndName "${Group}" ${Name}"

                 

                Thanks

                Siddu