1 Reply Latest reply on Sep 14, 2015 8:48 PM by Bill Robinson

    Passing parameters from one job to another in a Batch file

    James Donohue



      I have a batch job that does the following in sequence:

      1. Bl Package: Deletes 'Extended Object scripts' from the target Server's CT folder
      2. Discovery Job: Runs Discovery
      3. NSH script (type 1): Deletes the $HOST Component(s) from the Template


      I have to explicitly create variables for the Component Template Group and Name within the script. Which means, every time I need to execute this job in a Batch file, I'll need to change the variable to match the Components I'm looking to delete. My question is:


      Is there a better way to define these variables in the 'Master' Batch Job and have the NSH script pick them up? This way I could use the one script in whatever Batch Jobs I need it.


      This is the dirty version (still cleaning it up):

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



      echo $HOST


      CT_Group="/Applications/GWMT/GWMT Server Infrastructure/Windows/7. Special Purpose Configuration(SPC)"

      CT_Name="7.1 SPC-INF MSPTool-Hotfix Configuration"

      blcli_execute Template getDBKeyByGroupAndName "$CT_Group" "$CT_Name" > Nul

      blcli_storeenv templatekey

      echo "Template key: $templatekey"


      SERVER1_ID=`blcli Server getServerIdByName $HOST` > Nul

      echo "Server ID is: $SERVER1_ID"


      #COMPONENT_KEY=`blcli Component getComponentKeyByTemplateKeyAndServerId $templatekey $SERVER1_ID 0` 

      blcli_execute Component getComponentKeyByTemplateKeyAndServerId $templatekey $SERVER1_ID 0 >/dev/null

      if test $? -ne 0


          echo "Component Key is NOT found"


          blcli_storeenv COMPONENT_KEY

          echo "Component Key is: $COMPONENT_KEY"

          echo "$COMPONENT_KEY"

          blcli_execute Component deleteComponentByDBKey $COMPONENT_KEY 

          if test $? -ne 0


              echo "Failed to delete Component!"


              echo "Successful: Component for '$CT_Name' has been deleted for $HOST"





        • 1. Re: Passing parameters from one job to another in a Batch file
          Bill Robinson

          first i'd make sure you are using blcli_execute for everything, includeing the getServerIdByName call...


          what does 'Deletes 'Extended Object scripts' from the target Server's CT folder' ?   what is a 'target server's ct folder' ?  and why do you need a blpackage to do this ?


          why are you running discovery (to create/validate the components) and then deleting them ?


          why not do the whole thing in a single nsh script ?