2 Replies Latest reply on Jun 12, 2012 1:19 PM by Brandon Gillis

    Copy and execute nsh script on target server

      Hi all,


      I am attempting to execute an NSH script on a remote machine- and I need it to be run as an NSH script.


      As I understand the script options-

      1. executes the script on the app server against the target machines (i.e. script.nsh is run on BL-APP01 against Target.local)

      3. pushes the script to the target server and executes it using the default shell of the target server (i.e. script.bat is run on Target.local)


      What I need is a hybrid of the two- I need BSA to copy the script.nsh to my target server (Target.local) and execute it on the target server (Target.local)


      The reason I need this is that we are implementing an import/export solution where we run a script on our target server that:


      1. Connects to the Dev environment and exports a package

      2. Disconnects from Dev

      3. Connects to the PROD environment and imports the package to PROD.


      We have a "Transfer" server where everything is taking place.


      If I log into the Transfer server, place the nsh script in /c/tmp and execute it using the nsh shell (locally) - it works without a problem.


      Is there an option in BSA to copy the script.nsh file to my "Transfer" server and execute it from the "Transfer" server. (so that it picks up the local Auth profiles and exports the packages to a local directory)


      I have tried specifying the nsh shell in the batch script (using #!/bin/nsh) but that apparently doesn't work in Windows Batch. Is there any way to tell the Batch script that I want to use the nsh shell (similar to a linux script)?


      Any help would be appreciated.

        • 1. Re: Copy and execute nsh script on target server
          Bill Robinson

          If nsh is installed on the target system and you use the right shebang for the script I think runscript will run the right shell so a type 3 should work.  /bin/nsh does not exist on a windows box though and windows doesn’t really understand that anyway.


          So why don’t you make this a type 1 or type 2 script, have the script echo the bit you want to into a file and then nexec nsh and run it like:


          Nexec SERVER nsh –c “yourscript.nsh args”

          • 2. Re: Copy and execute nsh script on target server

            Thanks Bill!


            What we ended up doing is letting the script reside locally on our transfer server- then we setup a type 1 NSH script that simply ran the nexec hostname nsh -c "nsh /path/to/script/script.nsh arg1 arg 2 arg3 etc" command to excute the script.


            Using this solution we were actually able to pass arguments to our NSH script and execute it locally on our Transfer server.


            P.S. it didn't work correctly unless I put the nsh inside the double quotes. If I just ran nexec hostname nsh -c "script.nsh" it still tried to connect from the app server.


            Thanks again!