9 Replies Latest reply on Sep 5, 2013 8:09 AM by Jim Wilson

    NSH Scripting

    David Hawkes

      I have a script that uses the ndf command to output the disk usage for all my Servers which outputs everything to a text file for each Server. Like below



        SERVERNAME=$(hostname | tr "[:lower:]" "[:upper:]")


      DATE=`date +"%m%d%y"`










      # Create directory.




      mkdir -p "${REPOSITORY}/${FOLDERNAME}"




      echo "Logging Disk output to: ${ZOUTFILE2}"


      BL2=$(ndf -c -H -h ${SERVERNAME})




      echo "${BL2}" >> "${REPOSITORY}/${FOLDERNAME}/${ZOUTFILE2}"


      BL2=$(ndf -c -H -h ${SERVERNAME})









      I then have a seperate VBScript that gathers each txt file and adds it all into a CSV


      Is there any way of adding the OS Version to the coomand or an easier way of doing this

        • 1. Re: NSH Scripting
          Naveen Anne

          the following command gives you the OS of the target;



          if you do : uname -a , that also gives you the OS, hostname and the OS release version. See below for example from my VM:

          WINDOWS VM:

          bsarasvr% uname


          bsarasvr% uname -a

          WindowsNT bsarasvr 5.2 3790 i686 i386


          LINUX VM:

          bmc-bl# uname


          bmc-bl# uname -a

          Linux bmc-bl 2.6.18-194.17.4.el5 #1 SMP Mon Oct 25 15:51:07 EDT 2010 i686 x86


          Your strategy of creating individual files and consolidating into one file seems to be fine.


          Alternatively, you can put all of your script into an Extended Object in BSA and create a snapshot job to snapshot and gather the data. Then, you can create a report in BDSSA to display the results of the extended object.

          • 2. Re: NSH Scripting
            David Hawkes

            Can that be added to my Disk Usage command below so that each row in my Text file has the OS at the end


            BL2=$(ndf -c -H -h ${SERVERNAME})






            • 3. Re: NSH Scripting
              Naveen Anne

              You can concatenate the uname  command in your echo statement while writing the output to ZOUTFILE like this:



              echo "${UN}":::"${BL2}" >> "${REPOSITORY}/${FOLDERNAME}/${ZOUTFILE2}"

              • 4. Re: NSH Scripting
                Bill Robinson

                yeah - i don't think that's doing to work naveen - that just puts the uname at the beginning of the first line - so you want something like:



                ndf -c -H -h ${SERVER}" | awk -v val="$(cd //${SERVER};uname)" '{print $1,$2,$3,$4,val}'

                • 5. Re: NSH Scripting
                  David Hawkes

                  Script now looks like this



                  echo "Logging Disk output to: ${ZOUTFILE2}"


                  BL2=$(ndf -c -H -h ${SERVER}" | awk -v val="$(cd //${SERVER};uname)" '{print $1,$2,$3,$4,val}')




                  echo "${BL2}" >> "${REPOSITORY}/${FOLDERNAME}/${ZOUTFILE2}"


                  Not getting any output from this though

                  • 6. Re: NSH Scripting
                    Naveen Anne

                    HI David

                    Instead of putting the command that Bill provided, first try and echo just the output of the command like this:


                    echo `ndf -c -H -h ${SERVER}" | awk -v val="$(cd //${SERVER};uname)" '{print $1,$2,$3,$4,val}'`


                    Please tell us what you see.

                    • 7. Re: NSH Scripting
                      Bill Robinson

                      yeah - that's true - if you don't need the BL2 variable, you can just echo the output of the ndf line directly into the output file.

                      • 8. Re: NSH Scripting
                        Nand Mhase

                        For windows use ver command

                        It will return OS Verision in []

                        • 9. Re: NSH Scripting
                          Jim Wilson

                          Hi David Hawkes


                          Did this get resolved?

                          If so, please can you update the discussion thread with details so that is can be marked as answered.


                          Thanks & Regards,

                          Jim (Community Manager/Facilitator)