14 Replies Latest reply on Apr 28, 2014 8:44 PM by Barry McQuillan Branched from an earlier discussion.

    BLCLI question

      HI Bill,

      Please cna you help me with a query:

      I want to provide a string input to a BLCLI command from the command

      prompt,outside the nsh script. How do i make BLCLI accept it please?

      I am getting the following error:

       

      Error:

      Authentication succeeded: acquired session credential

      Command execution failed.

      com.bladelogic.om.infra.cli.factory.CommandNotFoundExc

      eption: Found command 'Job.executeAgainstServers' but with mismatching

      arguments

      . : java.lang.IllegalArgumentException: Wrong number of arguments provided

      to me

      thod : executeAgainstServers expected : 2 received : 1

       

      code:

       

      blcli_connect

      serverList=&&"$1"

      echo $serverList

      #Netbackup_PBX_Restart#

      blcli_execute Job executeAgainstServers "DBKey:SJobKeyImpl:225041-2"

      $serverList

       

      Now this code is being called by a command prompt windows batch file where

      i will provide the input, say for eg: win1.bat serverA...this serverA is

      the input to the serverList=&&"$1".

       

      Please advise.

      Thanks,

      Anish

        • 1. Re: BLCLI question
          Joe Piotrowski

          Branched this as a new question.

          • 2. Re: BLCLI question
            Bill Robinson

            blcli_connect

            serverList="$1"

            echo $serverList

            #Netbackup_PBX_Restart#

            blcli_execute Job executeAgainstServers "DBKey:SJobKeyImpl:225041-2" "$serverList"

            • 3. Re: BLCLI question


              Hi All,

               

              Appreciate your help but still getting error.

              I am giving the full set of commands being used right from the windows batch till nsh command:

               

              windows batch:

              cd D:\anish\scripts

              SET SERVERNAME=%1

              nsh bl_pbx_Windowsv1.nsh SERVERNAME

               

              NSH file:

               

              blcli_connect

              serverList="$1"

              echo $serverList

              #Netbackup_PBX_Restart#

              blcli_execute Job executeAgainstServers "DBKey:SJobKeyImpl:225041-2" "$serverList"

               

              Execution and Error:

              D:\anish\scripts>bl_pbx_Windowsv1.bat ServerA

              D:\anish\scripts>cd D:\anish\scripts

              D:\anish\scripts>nsh bl_pbx_Windowsv1.nsh
              Authentication succeeded: acquired session credential

              Command execution failed. com.bladelogic.om.infra.cli.factory.CommandNotFoundExc
              eption: Found command 'Job.executeAgainstServers' but with mismatching arguments
              . : java.lang.IllegalArgumentException: Wrong number of arguments provided to me
              thod : executeAgainstServers expected : 2 received : 1


              Please can you advise where i am going wrong:

              • 4. Re: BLCLI question
                Bill Robinson

                why are you doing this:

                SET SERVERNAME=%1

                nsh bl_pbx_Windowsv1.nsh SERVERNAME

                 

                where are you getting '%1' from ?  you should be doing:

                nsh bl_pbx_Windowsv1.nsh YOURACTUALSERVERNAMEHERE

                • 5. Re: BLCLI question

                  Hi Bill,

                   

                  Thanks for getting back to me.

                   

                  i am trying to provide input to the nsh file from an excel via the windows

                  batch...I am already successful ( thanks to you ) in importing it from a

                  txt file. but in this case the excel will be created from an email which

                  will feed in the server name to the script...Thus initially i was trying

                  to feed in  the data manually to the windows batch file.

                   

                  please advise if the method was incorrect.

                  Thanks, Anish

                  • 6. Re: BLCLI question
                    Bill Robinson

                    what does the excel file look like?  what is in it specifically that you are trying to read ?

                     

                    and you want to get something out of this file (the list of servers?) and feed that into the nsh command ?

                     

                    i'm not sure why you are trying to use batch and nsh here.  just use nsh...

                    • 7. Re: BLCLI question

                      Hi Bill,

                       

                      The excel file would consists of error codes and server names. these

                      servers names would be used to call different nsh scripts based on teh

                      error code.

                      Please could you guide me as to how do i call the nsh only without the

                      batch please? I am using the windows batch to call the nsh script and input

                      would be provided from excel...

                      Please could you let me know how do I feed in the server name from excel

                      directly to the nsh..

                       

                      Thanks in advance for your help.

                       

                      thanks, Anish

                      • 8. Re: BLCLI question
                        Bill Robinson

                        show me an example line or lines.

                         

                        also, by 'excel' i hope you mean csv format...

                        • 9. Re: BLCLI question

                          Hi Bill,

                           

                           

                            error code

                           

                          Server

                           

                          20

                           

                          serverA

                           

                          and the file is being created in excel format only.

                          • 10. Re: BLCLI question
                            Bill Robinson

                            you can't read a xls format from the commandline.  it needs to be a csv format, and it needs to be like:

                             

                            Error Code,Server

                            serverA,20

                             

                            in plain text...

                            • 11. Re: BLCLI question

                              Hi Bill,

                               

                              Thanks for the informantion. I will recheck.

                               

                              Thanks, Anish

                              • 12. Re: BLCLI question

                                Hi Bill,

                                 

                                one query before I recheck:

                                Suppose i want to manually enter the server name into windows batch such

                                that NSH would pick it automatically when called.

                                Any ideas if that can be done please?

                                I mean like addition of 2 numbers where input is given outside the program

                                by user

                                 

                                thanks, anish

                                 

                                On Fri, Apr 25, 2014 at 2:55 PM, Anish Chatter Anish <anish.161083@gmail.com

                                • 13. Re: BLCLI question
                                  Bill Robinson

                                  you have a nsh script file.  the nsh script will take arguments.  in the script you do something w/ the args.

                                   

                                  so your script has:

                                  ----

                                  #!/bin/nsh

                                  server=${1}

                                  code=${2}

                                   

                                  echo "${server} ${code}"

                                  ----

                                  you run the script like

                                   

                                  nsh script.nsh serverA code1

                                  • 14. Re: BLCLI question
                                    Barry McQuillan

                                    Another option could be to pass the file directly to a NSH script and have everything happen inside it (provided it is a csv file you could use something like:

                                     

                                    #!/bin/nsh

                                    CSVFILE=<pathToCSVFile> or ${1} if you want to pass the filelocation/name into script as a variable.

                                     

                                    while read LINE
                                    do


                                    # Build array by splitting LINE using comma
                                    SERVERANDERRORCODE_ARRAY=("${(s/,/)LINE}")

                                     

                                    # Set server and errcode
                                    SERVER=$SERVERANDERRORCODE_ARRAY[1]
                                    ERRCODE=$SERVERANDERRORCODE_ARRAY[2]

                                     

                                    # excute remediation command for relevant errocode

                                    case $ERRCODE in

                                    errcode1)

                                      ##<some command that you want to perform using $SERVER and errcode1>

                                      ;;

                                    errcode2)

                                      ##<some command that you want to perform using $SERVER and errcode2>;;

                                      *)

                                      ##<some command that you want to perform when errorcode not matched>;;

                                    esac

                                     

                                    done < $CSVFILE