7 Replies Latest reply: Aug 26, 2014 6:35 AM by Bill Robinson RSS

nsh scriptutil command problem

Jeff Orndorff

I am familiar with running the the scriptutil command from nsh.  I have been successful using it under nsh on a Linux server to remotely execute shell scripts on other Linux servers.

 

I would like to use it on a Windows (2008R2) server to execute shell scripts on a Linux server.  I have encountered two problems.

 

The first problem is the host file and sensor script seem to require fully path names when executing the command.  For example:

 

WIN2008R2# cat hosts hosta.domain.com hostb.domain.com

WIN2008R2# cat test.sh

echo "this is a test running on host `hostname`"

uname -a

sleep 10

WIN2008R2# scriptutil -f hosts -s test.sh

scriptutil: Unable to load hosts file hosts: No error

Usage: scriptutil [-d tmpdir] [-f file] [-h host] [-l]

         [-o file] -s scan [-x arg]

BladeLogic security scanner

         -?          Output this message and exit

         -d tmpdir    Remote staging directory (default: /tmp)

         -f file      Name of file containing list of host to run scan against

         -h host ...  Add host to list of hosts to run scan against

         -l          List all scanners available and exit

         -o file      Name of output file (def: stdout)

         -s name ...  Name of scanners to run

         -x arg      Pass arg to sensor

 

Once I use a full path name, the scriptutil command only executes the shell script (scanner) on the fist host in the host file.  All other cannot seem to locate the scanner.  For example:

 

WIN2008R2# scriptutil -f /c/Users/jmorndorff-admin/hosts -s /c/Users/jmorndorff-admin/test.sh

Unable to copy script "/c/Users/jmorndorff-admin/test.sh" to host hostb.domain.com: No such file or directory

this is a test running on host hosta.domain.com

Linux hosta.domain.com 2.6.18-308.1.1.el5 #1 SMP Fri Feb 17 16:51:01 EST 2012 x86_64 x86_64 x86_64 GNU/Linux

WIN2008R2#

Can anyone give me a clue to better understand this behavior?

  • 1. nsh scriptutil command problem
    Jeff Orndorff

    I just found that I if I include the host name in the sensor path, then the scriptutil will execute.

     

    Example:

    WIN2008R2# scriptutil -s //WIN2008R2.main.ads.com/c/Users/jmorndorff-admin/test.sh -h hosta.domain.com -h hostb.domain.com

    this is a test running on host hosta.domain.com

    Linux hosta.domain.com 2.6.18-308.1.1.el5 #1 SMP Fri Feb 17 16:51:01 EST 2012 x86_64 x86_64 x86_64 GNU/Linux

    this is a test running on host hostb.domain.com

    Linux hostb.domain.com 2.6.18-308.1.1.el5 #1 SMP Fri Feb 17 16:51:01 EST 2012 x86_64 x86_64 x86_64 GNU/Linux

    WIN2008R2#

     

    That is painful - wish there was a way to just use the filename without the path.

  • 2. Re: nsh scriptutil command problem
    Bill Robinson

    Script util assumes you have the files in the NSH/share/sensors directory on the system the nsh binary was launched from.

  • 3. nsh scriptutil command problem
    Jeff Orndorff

    It is inconsistent between Windows and Linux.

     

    On Windows you need to provide a full pathname for the scanner (-s option) and the host (-f option).  You can only provide a file name on Linux.

     

    Also - it is strange how when using a full path name (without the host name prefix) the scriptutil will be successful on the first host in the list only.

  • 4. Re: nsh scriptutil command problem
    Bill Robinson

    Where are you running nsh from?

    What is in the NSH/share/sensors directory on that system?

     

    “//WIN2008R2.main.ads.com/c/Users/jmorndorff-admin” is not the NSH/share/sensors directory so I would expect you to have to provide the explicit path.

     

    If you put the files in the ‘NSH/share/sensors’ directory on the system that you run the nsh binary this will work, however there are some naming conventions and formatting rules in the file to follow.

  • 5. nsh scriptutil command problem
    Jeff Orndorff

    I am used to using the scriptutil command on a Linux server, similar to the example in the NSH Command Reference:

     

    Example of using an existing script

    host% cd //athens/tmp

    athens%

    cat rr

    pwd

    athens% scriptutil -h rome -s rr -d /tmp/nsh

    /tmp/nsh

    I guess on a Windows server, you have to fully qualifiy the path name of the script if it is not in the local sensors directory. 

     

    Thanks.

  • 6. Re: nsh scriptutil command problem
    suresh balla

    Jeff,

    yes, on windows we don't need scriptutil if it is nsh script. we can that script directly. you need to place this script on file server under extended_objects dir.

    for scriptutil, it will check all the script under NSH/share/sensors, these script/executables copied to target and ran over there. they will executed in that OS environment.

    bat, exe or vb script etc on windows and similar shell script on linux/AIX/Unix/Solaris.

  • 7. Re: nsh scriptutil command problem
    Bill Robinson

    If you put the file name in the NSH/share/sensors directory on the system running scriptutil and follow the scriptutil naming convention and formatting then you only need to use the script name (it should show up in scriptutil -l)