Executing scripts from SLX-OS

From the SLX-OS CLI, you can execute scripts that you copied to flash memory or created in the SLXVM Linux shell.

Downloading a script to the SLX-OS device

After writing and testing a user-defined script file, copy it from an accessible network location to the flash memory of the SLX-OS device.

device# copy ftp://MyUserID:MyPassword@10.10.10.10//<copy_script.sh> flash://copy_script.sh

After copying the script to the device, verify that the script file is displayed with the list of files in the flash memory of the device.

device# dir
total 24
drwxr-xr-x   2 root     sys          4096 Oct 26 15:22 .
drwxr-xr-x   3 root     root         4096 Oct  1  1970 ..
-rw-r--r--   1 root     root         1051 Oct 24 16:09 copy_script.sh
-rw-r--r--   1 root     root          207 Oct 24 16:09 create_vlans.py
-rw-r--r--   1 root     sys           557 Oct 26 10:37 defaultconfig.novcs
-rw-r--r--   1 root     sys           778 Oct 26 10:37 defaultconfig.vcs

1922789376 bytes total (828317696  bytes free)
If the copied script does not have executable permissions, you need to assign executable permissions from the SLXVM Linux shell. Note that you need root access for this action, as described in "Escalating Linux permissions to root."
[root@SLX]# cd /var/config/vcs/scripts/
[root@SLX]# chmod 755 copy_script.sh
[root@SLX]# ls -lart copy_script.sh
-rwxr-xr-x 1 root root 1051 Oct 24 16:09 copy_script.sh

You can also display the contents of a script file.

device# show file copy_script.sh

Creating scripts in the Linux shell

You can create scripts by using the Linux shell vi editor, as in the following example.

device# start-shell
Entering Linux shell for the user: admUser
[admUser@SLX]# cd scripts
[admUser@SLX]# vi create_script.sh

After you write the script, make sure that it exists in the /fabos/users/admin/script directory and is executable under Linux.

[admUser@SLX]#pwd
/fabos/users/admin/scripts

Running scripts from the SLX-OS CLI

You can run scripts directly from SLX-OS CLI. Enter oscmd followed by the name of the script.

device# oscmd my_script