4 Replies Latest reply on Sep 29, 2010 10:28 PM by Amir Khamis

    Using a NSH Script with Extended Objects

    Amir Khamis


      I am trying to build an extended object to execute a command on a remote server using nexec.  If I pass a simple command to nexec, works great.  If I try to be sophisticated and write a script that will utilize a for statement, maybe an if else scenario, I get an error message.

      Is this some kind of limitation I am having? Or I simply need to do that in a certain way?  I do need the extended object so I use it for auditing.

      What are our best practices for writing complex (script based) extended objects?


        • 1. Re: Using a NSH Script with Extended Objects

          It all depends on what you are doing. It really sounds like you need to write a shell script and use scriptutil to execute it. Are your end targets Unix based servers?

          • 2. Re: Using a NSH Script with Extended Objects
            Bill Robinson

            Why do the for on the box, w/ nsh you can do things like:


            for server in $serverlist


                 nexec $server sh -c "<some command>"

                 foo=`nexec $server sh -c "<some other command>"

                 if [ $foo = bar ]


                      echo hello



            • 3. Re: Using a NSH Script with Extended Objects

              If you want to execute a simple command, then just enter the command you want run under "Command / Script" and select "Remote Execution" as the "Execution Type".  The command will be spawned out on the target system.  This method does not support pipes (e.g. cmd1 | sort) and, I suspect, would probably not deal well with shell metacharacters (wildcards, parentheses, etc).


              If you need multiple commands, then put it in a shell script file.  You can use scriptutil, runscript, or nsh -c in the "Command / Script" field to make your script run out on the target system.  You will not be mixing 'nexec' into your script; your entire script is exec'ed out onto the system.


              It seems to me almost as if you're taking the initial concept of being able to use nexec to run small bits out on remote systems and trying see Extended Objects as centralized code that can do the same thing.  Instead, think of Extended Objects as a library of code that can be copied out to local contexts and run locally, with results returned to the center.


              Does that help any?

              • 4. Re: Using a NSH Script with Extended Objects
                Amir Khamis

                thanks guys, all your comments where very helpful and solved the issue I had.

                thank you