1 2 Previous Next 18 Replies Latest reply on Jan 11, 2011 10:06 PM by Raghava Sanam

    Passing System Properties to NSH Script Job

      Hi All,

       

           I want to pass the system properties to my NSH script job. Is it possible, please let me know.

       

      Example:

      #metastat d10   (note d10 populated as server property value).

       

      my NSH script job would be:

      nexec ??TARGET.IP_ADDRESS?? metastat ??TARGET.SVM_ROOT_DISK??

       

      My script Job is failed with below error:

       

      //@/C/Program Files/BMC Software/BladeLogic/8.0/NSH/tmp/application_server/scripts/job__7d62819d-2e20-42e6-be69-f59614e7b16f/script_DBKey-SJobKeyImpl-2000199-2__4943376c-fee4-467d-8d93-f08a00cb0787.2011460.1_SVM.nsh:1: no matches found: ??TARGET.IP_ADDRESS??

       

      Ofcourse i'm doing wrong. Please let me know the right way to pass the system proprties as parameter/argument to my NSH script job.

       

      Kindly do the needful ASAP.

        • 1. Re: Passing System Properties to NSH Script Job
          Bill Robinson

          You need to either use the blcli to query for that information, or pass those properties into the script parameters and reference them as normal arguments ($1, $2, etc)

          • 2. Passing System Properties to NSH Script Job

            Hi Bill,

             

                      Thanks for your valuable inputs. I did the same thing as you said  pass properties into the script parameters:

             

            Actual NSH Script Job:

            -------------------

            nsh -c "/d/abc.nsh" ??TARGET.IP_ADDRESS?? ??TARGET.SVM_ROOT_DISK??

             

            abc.nsh script fle:

            --------------------------

            nexec $1 metastat $2

             

            It failed with below error:

             

            //@/C/Program Files/BMC Software/BladeLogic/8.0/NSH/tmp/application_server/scripts/job__7d62819d-2e20-42e6-be69-f59614e7b16f/script_DBKey-SJobKeyImpl-2000199-2__4943376c-fee4-467d-8d93-f08a00cb0787.2011460.1_SVM.nsh:1: no matches found: ??TARGET.IP_ADDRESS??

             

            Even if doing wrong, kindly publish the right script if possible.

            • 3. Passing System Properties to NSH Script Job
              Bill Robinson

              ah - sorry - so I was thinking a nsh script object/job - not the actual script.

               

              if you are running this through the GUI as a job, you can use the properties.  if you are running this from the commandline the properties are not available like that.

               

              what kind of info are you trying to get?

               

              you may be better off at looking at 'blquery'

              • 4. Passing System Properties to NSH Script Job

                Hi Bill,

                 

                       I'm actually trying to run the above job through bladlelogic GUI and I got the above errors.

                 

                To be frank my intention was:

                 

                1. Before doing kernel patch on the solaris boxes we need to do the boot disk sanity checking i.e., for instance If my OS is under Solaris Volume Manager (SVM), then I should be able to boot from both primary disk and mirror disk.

                 

                2. Before doing kernel patching I have to break the mirror disk from primary disk.After breaking the mirror take a reboot of the server on primary boot device. If reboot is successful, then change the boot device path to mirror disk and take a reboot of the server.

                 

                The above 2 steps is for safety checking. That means, while doing kernel patching if something goes wrong and my server is not able to boot from the primary boot disk, then I will boot my server from the mirror disk. So, for that I have to check whether my mirror disk is fine or not.

                 

                I want to achive all these checkings through bladelogic. As of now we are doing it manually.

                 

                My Requirement in the form of commands:

                 

                1. Checking submirrors and it's state

                 

                #metastat d10  (nexec ??TARGET.IP_ADDRESS?? metastat ??TARGET.SVM_DISK??)

                 

                d10: Mirror

                    Submirror 0: d11

                      State: Okay

                    Submirror 1: d12

                      State: Okay

                 

                2. Break the mirror

                #metadetach d10 d12 ( (nexec ??TARGET.IP_ADDRESS?? metadetach ??TARGET.MIRROR_DISK1??)

                 

                3. Take a reboot

                #init 6 (nexec ??TARGET.IP_ADDRESS?? init 6)

                 

                4. After reboot change the boot-device values so that the system tries to  boot from the mirror in case one of them is not available.

                # eeprom boot-device="rootdisk rootmirror net"

                 

                5. Take a reboot

                 

                If i'm able to boot successfully from both primary and mirror disks, I can go ahead for kernel patching without any hesitation.

                 

                So, here i'm trying to write a NSH script job and passing the server properties to the script and executing the script on GUI.

                 

                 

                So, this is my entire story. Sorry, If im boring you.

                 

                Please help me out to achieve this.

                • 5. Passing System Properties to NSH Script Job

                  Hi Bill,

                   

                        Could you update me on this. I explained the requirement in my trailing mail.

                   

                  Raghava

                  • 6. Passing System Properties to NSH Script Job
                    Bill Robinson

                    when you say 'run this through the gui' do you mean running it as a job?

                     

                    if so... when you create the script object you can define parameters to pass into the script as arg1, arg2, etc. 

                     

                    so set the SVM_DISK property and pass it as $1, then run:

                     

                    nexec -e metastat ${1}

                     

                    in your script.

                    • 7. Passing System Properties to NSH Script Job

                      Thanks Bill, that works. One further question.

                       

                      i'm using non-NSH script type and i'm passing 2 parameters to my script as below:

                       

                      /usr/sbin/metadetach $svm_root_disk $svm_sub_mirror and this script failed with below error:

                      "usage:  metadetach [-s setname] [-f] mirror submirror". But if run the same command on my solaris box by replcing parameters with actual values it executed successfully.

                       

                      If I pass 1 parameter to my script then its working.

                       

                      The problem when i'm executing the above command/script with 2 parameters. Kindly do the needful.

                       

                      Raghava.

                      • 8. Re: Passing System Properties to NSH Script Job
                        Bill Robinson

                        a non-nsh script does not need the 'nexec' - the script is copied over to the target and executed in the default shell. (eg not nsh)

                         

                        what is the line for the metadetach in your script and what is it when you run it on the box?

                        • 9. Passing System Properties to NSH Script Job

                          Hi Bill,

                           

                               Thanks for reply. Here i'm using non-nsh command as a script.

                           

                          metadetach $svm_root_disk $svm_sub_mirror    -    (this command will break the submirror from main mirror)

                           

                          The above command/script returning the below errors when I executed the job:

                          "usage:  metadetach [-s setname] [-f] mirror submirror"

                          "metadetach [-s setname] [-f] trans"

                           

                          I traced it that it's not considering the second parameter ($svm_sub_mirror). Because if I run the same command without second parameter in solaris:

                           

                          # metadetach d10

                          usage:  metadetach [-s setname] [-f] mirror submirror

                                  metadetach [-s setname] [-f] trans

                           

                          But actually I have to pass the second parameter also then only my command will execute without errors.

                           

                          #metadetach d10 d12   (Actual solaris command)

                           

                          Kindly do the needful.

                          • 10. Re: Passing System Properties to NSH Script Job
                            Bill Robinson

                            So are you passing the 2nd argument to the script object/job and reading it in ?

                            • 11. Passing System Properties to NSH Script Job

                              Yes, you are right. I'm passing both the arguments to the script.

                              • 12. Re: Passing System Properties to NSH Script Job
                                Gerardo Bartoccini

                                What if you echo the arguments first?

                                 

                                echo $1 $2

                                • 13. Passing System Properties to NSH Script Job

                                  I executed the below non-nsh script and the job got succeded but abc.txt file doesn't have any value

                                   

                                  echo $svmrootdisk $svmsubmirror >/tmp/abc.txt

                                   

                                  If I executed the same from in solaris the below is output

                                   

                                  #echo d10 d12

                                  d10 d12

                                  • 14. Re: Passing System Properties to NSH Script Job
                                    Gerardo Bartoccini

                                    How do you populate these variables?

                                    When you pass parameters they get populated into $1, $2, etc., so you have to do the following:

                                     

                                    svmrootdisk=$1

                                    svmsubmirror=$2

                                     

                                    Are you doing something like this?

                                    1 2 Previous Next