script

Use this command to execute a script file.

Syntax

script filename [arg1] [arg2] [arg3] [arg4] [arg5] [arg6] [arg7]

Parameters

filename Specifies the local path name to the file. Valid directories are the images/ directory, the slotN/ directory, and the slotN/usbN directory.
arg1 through arg7 Specifies up to seven arguments to the script.

Defaults

None.

Mode

All command modes.

Usage

The script file must first be created on a PC and copied to the S- K- and 7100-Series device using the copy command (copy) before the script can be executed. The file can contain any number of switch commands, up to a maximum file size of 128 kilobytes. Router commands cannot be included in the file. Scripts cannot be nested within the file. Note that the history command will not reflect the execution of commands within a script file.

If C2 security mode is enabled, access to secure logs using the script command is not supported while in Read-Write or Read-Only user modes.

Example

This example uses the copy command to copy the script file named “setport.scr” from IP address 10.1.221.3 to slot 4. Next, the contents of the file is displayed with the show file command. The script file requires two arguments, a port string (%1) and a VLAN id (%2). Finally, the script is executed, by specifying ge.1.1 as the first argument and 100 as the second argument.

System(rw)->copy tftp://10.1.221.3/setport.scr slot4/setport.scr
System(rw)->show file slot4/setport.scr
set port alias %1 script_set_port
set port vlan %1 %2 modify-egress
set port jumbo enable %1
set port disable %1
set port lacp port %1 disable
System(rw)->script slot4/setport.scr ge.1.1 100

When the script command parses the file and performs the command line argument substitution, the commands are converted to the following:

set port alias ge.1.1 script_set_port

set port vlan ge.1.1 100 modify-egress

set port jumbo enable ge.1.1

set port disable ge.1.1

set port lacp port ge.1.1 disabled

The converted strings are then executed by the CLI engine and the script command returns.