2 Replies Latest reply on Jul 12, 2005 2:24 PM by Jarrod Boland

    Annoyed by the lack of NSH Script Job output organization in %h/%f scripts?

      https://www.bladelogic.com/community/entry!default.jspa?categoryID=29&entryID=425

       

      Here's a workaround to better organize the output from NSH Script Jobs. I can't guarantee that it'll work forever, but it certainly can never hurt.

        • 1. Re: Annoyed by the lack of NSH Script Job output organization in %h/%f scripts?

          I prefer to use the first option, run each script separately against each host using runscript. That way, you get a log per server and success or failure by server.

           

          In your script, there is no need to loop through the list of hosts as you are just dealing with one.

           

          Within your script, if you need to know which server you are executing on, you can use the built in shell variable $NSH_RUNCMD_HOST.

           

          To test such a script (say called 'example.nsh') from the command line, you call it like so:

           

          runscript -h

           

          If you need to do computations which cross hosts, then clearly this approach will not work for you. However, I find it works great for the most part and simplifies my scripts. Jarrod, any major drawbacks that you can see to this approach?

          • 2. Re: Annoyed by the lack of NSH Script Job output organization in %h/%f scripts?

            I would agree that the first option in the NSH Script types (the runscript option) makes the most sense, but someimes scripts need to run through some central actions before looping through a host list. In those cases, this formatting trick will help users to better format their output.