1 Reply Latest reply on Jul 19, 2016 7:07 PM by Bill Robinson

    How to get nsh job key?

    michael huttner

      To:  Bill Robinson


      In one of your NSH script jobs, your code uses job arg $0 to parse the job's scriptpath for a "job key" string, which you then use to query for an nsh job key, eg:





      your code works like so



      > blcli_execute Job findByDBKey DBKey:SJobKeyImpl:6445573-28



      however, when I try this on a different job, it fails:

      nshJobKey= DBKey-SJobKeyImpl-2000182-2

      > blcli_execute Job findByDBKey DBKey-SJobKeyImpl-2000182-2

      Cannot store a failed command result


      Can you help explain what you are doing?

        • 1. Re: How to get nsh job key?
          Bill Robinson

          the code was like:





                  print_debug1 "Entering function: ${0}..."

                  local scriptPath="${1}" && print_debug2 "scriptPath=${scriptPath}"


                  local nshJobKey="`echo ${scriptPath} |sed "s/.*_\(DBKey.*\)__.*/\1/g" | sed "s/-/:/1" | sed "s/-/:/1"`"

                  BLCLICMD=(Job findByDBKey ${nshJobKey})


          BLCLICMD=(NSHScriptJob getScriptKey)

                  runBlcliCmd nshScriptKey



          the 'runBlcliCmd' is a wrapper to run the blcli.  and you seem to have cut out bits of what you are running because :


          > blcli_execute Job findByDBKey DBKey-SJobKeyImpl-2000182-2

          does not throw:

          "Cannot store a failed command result"

          blcli_storeenv will throw that error.


          so what exactly are you running ?  and you have the job key as soon as you run the echo and sed.  you don't need to use the blcli to get the job key.