1 2 Previous Next 24 Replies Latest reply on Apr 21, 2017 1:36 PM by Bill Robinson

    can we consider a blank parameter value in NSH script?

    Vadlla Saikiran

      Hello, we have an nsh job with 5 parameters. the 4th parameter is null as per the requirement.. when running a script which requires these parameters, because the 4th parameter value is null, 5th value is going to 4th's parameter value.

        • 1. Re: can we consider a blank parameter value in NSH script?
          Bill Robinson

          what version of bsa are you using ?  and this is in a job ?

          • 3. Re: can we consider a blank parameter value in NSH script?
            Vadlla Saikiran

            there is an nsh script and it has 4000 jobs referring to this script. previously it was type 3 nsh script which runs a bat file with the 5 args. we changed from type 3 to type 1 and modified the script into NSH script and started getting this error.

            • 4. Re: can we consider a blank parameter value in NSH script?
              Bill Robinson

              can you show a screenshot of the nsh script job parameters tab ?

              • 6. Re: can we consider a blank parameter value in NSH script?
                Bill Robinson

                that's working fine for me in 8.8.  can you attach the script ?

                • 7. Re: can we consider a blank parameter value in NSH script?
                  Vadlla Saikiran

                  #!/bin/nsh

                   

                   

                  #QUIET DOWN BSA

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

                   

                   

                  #SET VARIABLES

                  SERVERNAME="$NSH_RUNCMD_HOST"

                  STARTEAM_SERVER=${1}

                  STARTEAM_FOLDER=${2}

                  CHECKOUT_DIR=${3}

                  STARTEAM_VIEW=${4}

                  FILESET=${5}

                   

                   

                  #CHECK IF THIS IS A PRODUCTION/DR DEPLOY

                  IS_STARTEAM_VIEW_PROD=`echo "${STARTEAM_VIEW}" | grep -i prod | wc -l`

                   

                   

                  if [ "${IS_STARTEAM_VIEW_PROD}" -eq 1 ]; then

                   

                   

                    #CAPTURE JOB DB KEY BY PARSING IT OUT OF ECHO $0 COMMAND

                    DBKEYcalc=`echo $0 | awk -F'DBKey' '{print $2}' | awk -F'_' '{print $1}' | sed 's/-/:/1' | sed 's/-/:/1'`

                    DBKEY=`echo "DBKey${DBKEYcalc}"`

                   

                    #CAPTURE JOB GROUP ID TO USE LATER

                    blcli_execute Job getGroupId ${DBKEY}

                    blcli_storeenv jobGroupId

                   

                    #GET JOB FOLDER PATH USING JOB TYPE AND GROUP ID

                    blcli_execute Group getAQualifiedGroupName 5005 ${jobGroupId}

                    blcli_storeenv jobFolderPath

                   

                    #GET JOB NAME USING JOB DB KEY

                    blcli_execute Job getJobNameByDBKey ${DBKEY}

                    blcli_storeenv jobName

                   

                    #CAPTURE THE CHANGE RECORD NUMBER FROM THE ML_CRQ JOB PROPERTY

                    blcli_execute Job getFullyResolvedPropertyValue "NSH_SCRIPT_JOB" "${jobFolderPath}" "${jobName}" ML_CRQ

                    blcli_storeenv ML_CRQ

                   

                    #MAKE SURE THAT WE HAVE A CRQ NUMBER SUPPLIED, IF NOT, CAPTURE THE VALUE AS NULL

                    if [ "${ML_CRQ}" = '' ]; then

                    ML_CRQ="NULL"

                    fi

                   

                    #SET THE ML_CRQ JOB PROPERTY FOR JOB TO BLANK - THIS IS AN EXTRA SECURITY MEASURE PROPOSED BY FORREST TIFFANY

                    blcli_execute Job setPropertyValue ${DBKEY} ML_CRQ ""

                   

                    #PARSE THE PARENT FOLDER PATH AND JOB NAME TO MAKE IT EASIER TO LOOK JOB UP IN BDSSA

                    PARENTFOLDERPATH=`echo "${jobFolderPath}" | sed -e 's/\/\(.*\)\/.*/\/\1/'`

                    JOBFOLDERNAME=`echo "${jobFolderPath}" | awk -F/ '{print $NF}'`

                   

                    #THIS MAY POSE A POTENTIAL ISSUE DUE TO IT CAPTURING THE LAST RUN INSTANCE

                    blcli_execute JobRun findLastRunKeyByJobKey ${DBKEY}

                    blcli_storeenv RUNKEY

                   

                    #CAPTURE START_TIME OF THE JOB RUN

                    blcli_execute JobRun getStartTimeByRunKey ${RUNKEY}

                    blcli_storeenv START_TIME

                   

                    #CHECK IF STARTEAM_AUDIT DIRECTORY EXISTS, IF NOT, CREATE IT

                    if [ ! -d //EDS01/D/STARTEAM_AUDIT ]; then

                    mkdir //EDS01/D/STARTEAM_AUDIT

                    fi

                   

                    #CHECK IF HEADER ROW EXISTS IN CHANGE_LOG.CSV

                    HEADERCHECK=`grep PARENT_FOLDER_PATH,JOB_FOLDER_NAME,JOB_NAME,JOB_START_TIME,CHANGE_RECORD_NUMBER,STARTEAM_SERVER,STARTEAM_FOLDER,CHECKOUT_DIR,STARTEAM_VIEW,FILESET //EDS01/D/STARTEAM_AUDIT/CHANGE_LOG.csv | wc -l`

                    if [ ${HEADERCHECK} -eq 0 ]; then

                    #CREATE HEADER ROW

                    echo "PARENT_FOLDER_PATH,JOB_FOLDER_NAME,JOB_NAME,JOB_START_TIME,CHANGE_RECORD_NUMBER,STARTEAM_SERVER,STARTEAM_FOLDER,CHECKOUT_DIR,STARTEAM_VIEW,FILESET" > //EDS01/D/STARTEAM_AUDIT/CHANGE_LOG.csv

                    fi

                   

                    #NEED TO CHANGE SERVER NAME TO - EDS01

                    #OUTPUT VARIABLES

                    echo "${PARENTFOLDERPATH}","${JOBFOLDERNAME}","${jobName}","${START_TIME}","${ML_CRQ}","${STARTEAM_SERVER}","${STARTEAM_FOLDER}","${CHECKOUT_DIR}","${STARTEAM_VIEW}","${FILESET}" >> //EDS01/D/STARTEAM_AUDIT/CHANGE_LOG.csv

                   

                  fi

                   

                   

                  echo 1.0 ${STARTEAM_SERVER}

                  echo 2.0 ${STARTEAM_FOLDER}

                  echo 3.0 ${CHECKOUT_DIR}

                  echo 4.0 echo${STARTEAM_VIEW}echo

                  echo 5.0 ${FILESET}

                   

                   

                  if [ "${FILESET}" = '' ]; then

                    #USE D:\\Secured_Scripts\\securecheckout_default.bat

                    nexec -i -l ${SERVERNAME} cmd /c 'D:\\Secured_Scripts\\securecheckout_default.bat "'${STARTEAM_SERVER}'" "'${STARTEAM_FOLDER}'" "'${CHECKOUT_DIR}'" "'${STARTEAM_VIEW}'"'

                  else

                    #USE D:\\Secured_Scripts\\securecheckout.bat

                    nexec -i -l ${SERVERNAME} cmd /c 'D:\\Secured_Scripts\\securecheckout.bat "'${STARTEAM_SERVER}'" "'${STARTEAM_FOLDER}'" "'${CHECKOUT_DIR}'" "'${STARTEAM_VIEW}'" "'${FILESET}'"'

                  fi

                  • 8. Re: can we consider a blank parameter value in NSH script?
                    Vadlla Saikiran

                    i tried echoing the args.. like

                    echo 1.0 ${STARTEAM_SERVER}

                    echo 2.0 ${STARTEAM_FOLDER}

                    echo 3.0 ${CHECKOUT_DIR}

                    echo 4.0 echo${STARTEAM_VIEW}echo

                    echo 5.0 ${FILESET}

                     

                    and the result is below:

                    Info04/19/2017 17:17:081.0 as-riscstartm02
                    Info04/19/2017 17:17:082.0 "IT_GVWB_USB_SYNC_BILLING_INFO_WMB\deployment\INT"
                    Info04/19/2017 17:17:083.0 "D:emp\RMT_BILLINFO333"
                    Info04/19/2017 17:17:084.0 echoecho
                    Info04/19/2017 17:17:085.0 BILLSERVICE_REST.bar
                    Info04/19/2017 17:17:11Error occurred:
                    Info04/19/2017 17:17:11Promotion State not found: BILLSERVICE_REST.bar
                    Info04/19/2017 17:17:11Exit Code 1
                    • 9. Re: can we consider a blank parameter value in NSH script?
                      Vadlla Saikiran

                      thought if we didn't declare any value for the arg.. then it will use the value declared in the NSH Script.. and in the script we declared it as STAGE.. it's not taking either..

                      • 10. Re: can we consider a blank parameter value in NSH script?
                        Bill Robinson

                        Put a ‘set –x’ at the top of the script under the shebang and re-run it and post the job run log.

                        • 11. Re: can we consider a blank parameter value in NSH script?
                          Vadlla Saikiran
                          Error04/19/2017 22:08:31+//@/D/BladeLogic/NSH/tmp/av-riscvmbmc002_job_01/scripts/job__06d57f81-b6c9-47ed-a397-349f96108854/64da7224-cfe7-4be3-ace4-62cb9c0410cb.script_DBKey-SJobKeyImpl-2749957-11_securecheckout.bat:4> blcli_setjvmoption '-Dcom.bladelogic.cli.execute.quietmode.enabled=true'
                          Error04/19/2017 22:08:31+//@/D/BladeLogic/NSH/tmp/av-riscvmbmc002_job_01/scripts/job__06d57f81-b6c9-47ed-a397-349f96108854/64da7224-cfe7-4be3-ace4-62cb9c0410cb.script_DBKey-SJobKeyImpl-2749957-11_securecheckout.bat:7> SERVERNAME=EDS01
                          Error04/19/2017 22:08:31+//@/D/BladeLogic/NSH/tmp/av-riscvmbmc002_job_01/scripts/job__06d57f81-b6c9-47ed-a397-349f96108854/64da7224-cfe7-4be3-ace4-62cb9c0410cb.script_DBKey-SJobKeyImpl-2749957-11_securecheckout.bat:8> STARTEAM_SERVER=as-riscstartm02
                          Error04/19/2017 22:08:31+//@/D/BladeLogic/NSH/tmp/av-riscvmbmc002_job_01/scripts/job__06d57f81-b6c9-47ed-a397-349f96108854/64da7224-cfe7-4be3-ace4-62cb9c0410cb.script_DBKey-SJobKeyImpl-2749957-11_securecheckout.bat:9> STARTEAM_FOLDER='"IT_GVWB_USB_SYNC_BILLING_INFO_WMB\deployment\INT"'
                          Error04/19/2017 22:08:31+//@/D/BladeLogic/NSH/tmp/av-riscvmbmc002_job_01/scripts/job__06d57f81-b6c9-47ed-a397-349f96108854/64da7224-cfe7-4be3-ace4-62cb9c0410cb.script_DBKey-SJobKeyImpl-2749957-11_securecheckout.bat:10> CHECKOUT_DIR='"D:\temp\RMT_BILLINFO333"'
                          Error04/19/2017 22:08:31+//@/D/BladeLogic/NSH/tmp/av-riscvmbmc002_job_01/scripts/job__06d57f81-b6c9-47ed-a397-349f96108854/64da7224-cfe7-4be3-ace4-62cb9c0410cb.script_DBKey-SJobKeyImpl-2749957-11_securecheckout.bat:11> STARTEAM_VIEW=''
                          Error04/19/2017 22:08:31+//@/D/BladeLogic/NSH/tmp/av-riscvmbmc002_job_01/scripts/job__06d57f81-b6c9-47ed-a397-349f96108854/64da7224-cfe7-4be3-ace4-62cb9c0410cb.script_DBKey-SJobKeyImpl-2749957-11_securecheckout.bat:12> FILESET=BILLSERVICE_REST.bar
                          Error04/19/2017 22:08:31+//@/D/BladeLogic/NSH/tmp/av-riscvmbmc002_job_01/scripts/job__06d57f81-b6c9-47ed-a397-349f96108854/64da7224-cfe7-4be3-ace4-62cb9c0410cb.script_DBKey-SJobKeyImpl-2749957-11_securecheckout.bat:15> IS_STARTEAM_VIEW_PROD=+//@/D/BladeLogic/NSH/tmp/av-riscvmbmc002_job_01/scripts/job__06d57f81-b6c9-47ed-a397-349f96108854/64da7224-cfe7-4be3-ace4-62cb9c0410cb.script_DBKey-SJobKeyImpl-2749957-11_securecheckout.bat:1> echo ''
                          Error04/19/2017 22:08:31+//@/D/BladeLogic/NSH/tmp/av-riscvmbmc002_job_01/scripts/job__06d57f81-b6c9-47ed-a397-349f96108854/64da7224-cfe7-4be3-ace4-62cb9c0410cb.script_DBKey-SJobKeyImpl-2749957-11_securecheckout.bat:15> IS_STARTEAM_VIEW_PROD=+//@/D/BladeLogic/NSH/tmp/av-riscvmbmc002_job_01/scripts/job__06d57f81-b6c9-47ed-a397-349f96108854/64da7224-cfe7-4be3-ace4-62cb9c0410cb.script_DBKey-SJobKeyImpl-2749957-11_securecheckout.bat:1> grep -D //EDS01/c/ -i prod
                          Error04/19/2017 22:08:31+//@/D/BladeLogic/NSH/tmp/av-riscvmbmc002_job_01/scripts/job__06d57f81-b6c9-47ed-a397-349f96108854/64da7224-cfe7-4be3-ace4-62cb9c0410cb.script_DBKey-SJobKeyImpl-2749957-11_securecheckout.bat:15> IS_STARTEAM_VIEW_PROD=+//@/D/BladeLogic/NSH/tmp/av-riscvmbmc002_job_01/scripts/job__06d57f81-b6c9-47ed-a397-349f96108854/64da7224-cfe7-4be3-ace4-62cb9c0410cb.script_DBKey-SJobKeyImpl-2749957-11_securecheckout.bat:1> wc -D //EDS01/c/ -l
                          Info04/19/2017 22:08:311.0 as-riscstartm02
                          Info04/19/2017 22:08:312.0 "IT_GVWB_USB_SYNC_BILLING_INFO_WMB\deployment\INT"
                          Info04/19/2017 22:08:313.0 "D:emp\RMT_BILLINFO333"
                          Info04/19/2017 22:08:314.0 echoecho
                          Info04/19/2017 22:08:315.0 BILLSERVICE_REST.bar
                          Error04/19/2017 22:08:31+//@/D/BladeLogic/NSH/tmp/av-riscvmbmc002_job_01/scripts/job__06d57f81-b6c9-47ed-a397-349f96108854/64da7224-cfe7-4be3-ace4-62cb9c0410cb.script_DBKey-SJobKeyImpl-2749957-11_securecheckout.bat:15> IS_STARTEAM_VIEW_PROD='       0'
                          Error04/19/2017 22:08:31+//@/D/BladeLogic/NSH/tmp/av-riscvmbmc002_job_01/scripts/job__06d57f81-b6c9-47ed-a397-349f96108854/64da7224-cfe7-4be3-ace4-62cb9c0410cb.script_DBKey-SJobKeyImpl-2749957-11_securecheckout.bat:17> [ '       0' -eq 1 ']'
                          Error04/19/2017 22:08:31+//@/D/BladeLogic/NSH/tmp/av-riscvmbmc002_job_01/scripts/job__06d57f81-b6c9-47ed-a397-349f96108854/64da7224-cfe7-4be3-ace4-62cb9c0410cb.script_DBKey-SJobKeyImpl-2749957-11_securecheckout.bat:81> echo 1.0 as-riscstartm02
                          Error04/19/2017 22:08:31+//@/D/BladeLogic/NSH/tmp/av-riscvmbmc002_job_01/scripts/job__06d57f81-b6c9-47ed-a397-349f96108854/64da7224-cfe7-4be3-ace4-62cb9c0410cb.script_DBKey-SJobKeyImpl-2749957-11_securecheckout.bat:82> echo 2.0 '"IT_GVWB_USB_SYNC_BILLING_INFO_WMB\deployment\INT"'
                          Error04/19/2017 22:08:31+//@/D/BladeLogic/NSH/tmp/av-riscvmbmc002_job_01/scripts/job__06d57f81-b6c9-47ed-a397-349f96108854/64da7224-cfe7-4be3-ace4-62cb9c0410cb.script_DBKey-SJobKeyImpl-2749957-11_securecheckout.bat:83> echo 3.0 '"D:\temp\RMT_BILLINFO333"'
                          Error04/19/2017 22:08:31+//@/D/BladeLogic/NSH/tmp/av-riscvmbmc002_job_01/scripts/job__06d57f81-b6c9-47ed-a397-349f96108854/64da7224-cfe7-4be3-ace4-62cb9c0410cb.script_DBKey-SJobKeyImpl-2749957-11_securecheckout.bat:84> echo 4.0 echoecho
                          Error04/19/2017 22:08:31+//@/D/BladeLogic/NSH/tmp/av-riscvmbmc002_job_01/scripts/job__06d57f81-b6c9-47ed-a397-349f96108854/64da7224-cfe7-4be3-ace4-62cb9c0410cb.script_DBKey-SJobKeyImpl-2749957-11_securecheckout.bat:85> echo 5.0 BILLSERVICE_REST.bar
                          Error04/19/2017 22:08:31+//@/D/BladeLogic/NSH/tmp/av-riscvmbmc002_job_01/scripts/job__06d57f81-b6c9-47ed-a397-349f96108854/64da7224-cfe7-4be3-ace4-62cb9c0410cb.script_DBKey-SJobKeyImpl-2749957-11_securecheckout.bat:87> [ BILLSERVICE_REST.bar '=' '' ']'
                          Error04/19/2017 22:08:31+//@/D/BladeLogic/NSH/tmp/av-riscvmbmc002_job_01/scripts/job__06d57f81-b6c9-47ed-a397-349f96108854/64da7224-cfe7-4be3-ace4-62cb9c0410cb.script_DBKey-SJobKeyImpl-2749957-11_securecheckout.bat:92> nexec -D //EDS01/c/ -i -l EDS01 cmd /c 'D:\\Secured_Scripts\\securecheckout.bat "as-riscstartm02" ""IT_GVWB_USB_SYNC_BILLING_INFO_WMB\deployment\INT"" ""D:\temp\RMT_BILLINFO333"" "" "BILLSERVICE_REST.bar"'
                          Info04/19/2017 22:08:34Error occurred:
                          Info04/19/2017 22:08:34Promotion State not found: BILLSERVICE_REST.bar
                          Info04/19/2017 22:08:34Exit Code 1
                          • 12. Re: can we consider a blank parameter value in NSH script?
                            Vadlla Saikiran

                            well, upon doing a research found out that the batch file is not accepting the null value.

                            Solution for the batch file is - Use %~x instead of %x (where x is your parameter number)

                            In our case, $4 is the parameter.. how can we use this in NSH?

                            • 13. Re: can we consider a blank parameter value in NSH script?
                              Bill Robinson

                              i'm confused.  you said this:

                              "because the 4th parameter value is null, 5th value is going to 4th's parameter value"

                              your echo outupt shows this:

                              Info

                              04/19/2017 17:17:081.0 as-riscstartm02
                              Info04/19/2017 17:17:082.0 "IT_GVWB_USB_SYNC_BILLING_INFO_WMB\deployment\INT"
                              Info04/19/2017 17:17:083.0 "D:emp\RMT_BILLINFO333"
                              Info04/19/2017 17:17:084.0 echoecho
                              Info04/19/2017 17:17:08

                               

                               

                               

                              the shell debug also shows this:

                              Error

                              04/19/2017 22:08:31+//@/D/BladeLogic/NSH/tmp/av-riscvmbmc002_job_01/scripts/job__06d57f81-b6c9-47ed-a397-349f96108854/64da7224-cfe7-4be3-ace4-62cb9c0410cb.script_DBKey-SJobKeyImpl-2749957-11_securecheckout.bat:11> STARTEAM_VIEW=''
                              Error04/19/2017 22:08:31

                              +//@/D/BladeLogic/NSH/tmp/av-riscvmbmc002_job_01/scripts/job__06d57f81-b6c9-47ed-a397-349f96108854/64da7224-cfe7-4be3-ace4-62cb9c0410cb.script_DBKey-SJobKeyImpl-2749957-11_securecheckout.bat:12> FILESET=BILLSERVICE_REST.bar

                               

                              so arg4 is blank, arg5 is set to what you are passing in for arg5.  what's the problem?

                              • 14. Re: can we consider a blank parameter value in NSH script?
                                Vadlla Saikiran

                                yes, it's showing "" aswell when doing nexec.. but the job is failing.. BMC support said the job should have a value for that arg and change the value to null in the script.. tried but didn't work..

                                1 2 Previous Next