Documentation forKiwi CatTools

Run external scripts in Kiwi CatTools

It is possible to run an external VB script from within the Device.CLI.Send commands activity and use the return value from the external script as part of a CLI command to be executed. When creating external scripts for use within CatTools, you will need to edit the script files using a script editor.

A number of useful Functions and Variables are exposed for use by external scripts.

Supported device scripts

  • Cisco.Switch.IOS
  • Cisco.Router.General
  • Cisco.Other.CUE
  • Cisco.Wireless.LAN
  • Cisco.WAE
  • Aruba.ArubaOS.General


To run an external script from within the Device.CLI.Send commands activity, commands should be entered in the following format:


  • PathToScript is the full path to the script to be run. It must be wrapped in quotation marks as shown.
  • VariableString is a string containing values to pass to the external script. It must be wrapped in quotation marks as shown, but cannot contain internal quotes. VariableString is optional as the script may not require variables.

You can pass more than one variable to the script, within the confines of the variable string. For example you could pass "255|127|1|2" as your variable string and use the external script to parse these into individual number values.

Only one %ctRunExternalScript command can exist per line.

External script parameters

  • The external script must include function Main, which is the script's entry point. Function Main must accept a string parameter:
    Function Main(VariableString)
  • The script always returns a value, even if the value is:Null
  • The script may parse VariableString and separate it into individual variables for use within the script.
  • The script has these Functions and Variables exposed to it.
  • The script stores values for use later using the functionality exposed by a scripting dictionary.

Scenario 1: Delete files from TFTP and run config

A script is run which deletes all files from the TFTP folder before the running config is copied into it. The external script does not require any parameters and returns a null value. The next command copy running tftp is then executed.

copy running tftp

Scenario 2: Send command to identify and enable specific port

A script is run which returns a value of the ports to enable based on the value of StringVariable. The variable is 5 in this case, which represents the slot number.

Set Port %ctRunExternalScript("C:\PortToEnable.txt","5") enable

After execution of the script, the command processed by the Device.CLI.Send commands activity in CatTools is:

Set Port 5/1-12 enable

Where 5/1-12 is the returned value from the function. This value is inserted into the final command used.

Scenario 3: Change hostname

The hostname is changed to a new hostname. No variables are passed.

Conf term
hostname %ctRunExternalScript("C:\hostnames.txt")
wri mem

Sample External Scripts

The following example can be applied to Scenario 2 above. The function returns a value based on the input string.

Function Main(inputString)
	Dim SelectionValue
	SelectionValue = Val(inputString)
	Main = ""
	Select Case SelectionValue
	Case 1
		Main = "1/1-12"
	Case 2
		Main = "2/1-12"
	Case 5
	Main = "5/1-12"
	End Select
End Function

The following script example can be applied to Scenario 3 above. Although the user is not passing an input string, CatTools passes a default null string. The inputString variable is still required in the function definition. The function itself is referencing cl.DeviceHostnameId, which is one of the variables made available to external scripts.

Function Main(inputString)
	If cl.DeviceHostnameId="MyRouter1" Then Main="MyNewRouterName1"
	If cl.DeviceHostnameId="MyRouter2" Then Main="MyNewRouterName2"
End Function