CLI-Script and CLI-Shell

Overview

The cli-script and cli-shell feature provides command automation and system command execution within the OcNOS command-line interface.

The cli-script function supports creation of script files that contain configuration mode and execution mode commands. These scripts can be executed in execution mode to apply the defined commands and store the resulting configuration on the system.

The cli-shell function enables execution of Linux bash commands directly from execution mode through the CLI.

Feature Characteristics

Supports creation of cli-script files using the cli-script file-name command.
Accepts configuration mode and execution mode commands as script input.
Supports execution control through delay and message commands.
Provides configurable behavior for error handling during script execution.
Allows execution of linux bash commands using the exec-shell linux command interface.
Stores cli-script files persistently on the file system.

Benefits

Enables automation of operational and configuration workflows.
Simplifies application of repetitive or grouped configuration changes.
Reduces manual configuration effort and execution time.
Provides controlled access to system-level commands from the CLI.

Limitations

Editing an existing cli-script is not supported through the CLI.
Modifying a script requires deleting and recreating the cli-script file.
Built-in linux shell commands are not supported through the exec-shell interface.
Improper use of cli-shell commands may affect system stability.

Configuration

CLI-Script Configuration

The cli-script feature allows the user to create a cli-script and add a set of commands to it, making it possible to apply a specific set of configurations at once when applying the cli-script. The main objective is to provide the creation of a cli-script in execution mode, with the cli-script file-name command, that enters the cli-script mode, and receives as input a series of commands. The name of the file has a limit of 128 characters and verifies invalid characters, such as >, <, *, among others.

1. Create a cli-script file and enter cli-script mode to define the sequence of commands.
Copy
OcNOS# cli-script TRANSLATION

This command creates a cli-script named translation and switches the CLI to cli-script mode.

2. Enter the configuration and execution mode commands that must be applied together when the script is executed.

Include all necessary commit commands within the script to ensure that configuration changes are applied.

Copy
OcNOS(cli-script)# configure terminal
OcNOS(cli-script)# netconf translation openconfig
OcNOS(cli-script)# commit

The load-cli-script command does not perform an implicit commit. Any configuration commands included in the script must explicitly contain commit statements.

3. Exit cli-script mode and save the script contents to the system.
Copy
OcNOS(cli-script)# cli-script-end

This action saves the cli-script file and returns the CLI to execution mode.

4. Execute the saved cli-script to apply the defined commands.
Copy
OcNOS# load-cli-script TRANSLATION
OcNOS# show running-config netconf translation

The system executes each command in the script sequentially.

CLI-Shell Configuration

1. Execute a Linux bash command directly from execution mode.
Copy
OcNOS# exec-shell ip netns exec zebosfib0 ip addr show eth1
2. Execute an existing shell script from the system.
Copy
OcNOS# exec-shell /root/test_hello.sh

Configuration for Delay and Message Commands

1. Configure execution delay.
Copy
OcNOS# delay 5
OcNOS# configure terminal
Enter configuration commands, one per line.  End with CNTL/Z.
OcNOS(config)#do delay 5
OcNOS(config)#
2. Display a custom message during execution.
Copy
OcNOS# message Test message
OcNOS# configure terminal
Enter configuration commands, one per line.  End with CNTL/Z.
OcNOS(config)# do message Test message

Validation

Validate the creation of a cli-script with the following show commands available in CLI Execution mode:

1. Verify cli-script creation.
Copy
#show cli-script all
Filename        Last Modified
EVPN-MAINT-1    01-01-2010
TRANSLATION     02-01-2010
INT-EXEC-2      04-01-2020
2. Verify cli-script content.
Copy
OcNOS#show cli-script content all
cli-script test
configure terminal
interface xe1
shutdown
commit
cli-script-end
cli-script test1
conf term
int xe1
shutdown
commit
cli-script-end

Configuration Snapshot

Copy
OcNOS#show running-config extended
!
! Software version: EC_AS7315-30X-OcNOS-AGGR-NA-7.1.0.999- 01/20/2026 17:36:25
!
! Last configuration change at 16:04:58 UTC Thu Jan 22 2026 by root
!
!
netconf translation openconfig
!
service password-encryption
!
!
!
snmp-server enable traps link linkDown
snmp-server enable traps link linkUp
!!
qos enable
!
tfo Disable
errdisable cause stp-bpdu-guard
feature dns relay
ip dns relay
ipv6 dns relay
!
ip vrf management
!
interface eth0
ip vrf forwarding management
ip address dhcp
!
exit
!
!
end
!
cli-script EVPN-MAINT-1
conf t
interface eth1
shutdown
commit
cli-script-end
cli-script TRANSLATION
conf
netconf translation openconfig
commit
cli-script-end
!
cli-script INT-EXEC-2
mtu 999
interface xe2
ip address 4.4.4.4/24
config terminal
interface xe1
shutdown
delay 20
no shutdown
commit
cli-script-end
#show cli-script EVPN-MAINT-1
conf t
interface eth1
shutdown
commit
OcNOS#show cli-script content all
cli-script EVPN-MAINT-1
conf t
interface eth1
shutdown
commit
cli-script-end

Implementation Examples

CLI-Script allows the user to execute a sequence of commands, facilitating the execution of multiple tests automatically, saving each test and pasting it to other devices with the copy and paste options.
Delay and message commands can be used inside cli-scripts to facilitate the understanding of the test execution process and what is being applied to the system in each moment.
EXEC-Shell commands can help productivity by allowing the user to execute shell commands directly in CLI, without having the need to exit execution mode to access root and execute the command.