As well as executing single commands against one SSH server or group of servers, you can also create more complicated scripts to run against your nodes.

This article will deal with creating a very simple script that creates a directory with a single file in it, then we'll run that script on a node.


Step 1: Create the script

In the admin web UI, navigate to Shell Scripts and click Create.

Give the script a Name, here we'll set it to createfileinfolder.

For the script itself, it can be any kind of script you want, such as bash etc, but here we are just going to directly type in the shell commands we want to run.

This example script is:

mkdir /tmp/testfolder
echo "This is a test file created for the scripting kb article" > /tmp/testfolder/testfile.txt


Click the Options tab. Here is where you would set the interpreter to use for this script. As we're just running shell commands directly, we can leave this as source ${script}.


Click the Roles tab. Set the Roles which will be allowed to run this script. Click Create to finish creating the script.



Step 2: Running the script and testing

Connect to the SSH Gateway via SSH.

Using the scripts command will show what script names are available to run.


The script can be run against a node using the nscript command, in the format nscript <node> <scriptname>

The image below shows the script being run and then we test that the script ran ok by seeing if we can print out the contents of that file using an nexec cat command.


Scripts can also be run again Server Groups using the gscript command.


In the admin web UI, navigate to Audit Log. Here you can see the events relating to the scripts that have been run.


Have more questions? Submit a request