Description

This article explains how to execute CLI commands from within the shell in EX Series switches.

 

Symptoms

There may be times when you need to run CLI-specific commands while in the shell prompt without going back and forth between the CLI and the shell. This article provides a method for executing CLI commands from the shell.

 

Solution

There is an "alias" or shortcut command, which allows users to execute CLI commands from the shell prompt. This is useful when troubleshooting or monitoring while in shell. Both root and non-root users can execute this command from the shell prompt. 

While in shell, use cli , and then the CLI command that you want to execute as follows:

root@host:RE:0% cli show interface terse
root@:RE:0% cli show interface terse
Interface Admin Link Proto Local Remote
ge-0/0/0 up down
ge-0/0/0.0 up down eth-switch
ge-0/0/1 up down
ge-0/0/1.0 up down eth-switch
ge-0/0/2 up up
ge-0/0/2.0 up up eth-switch
ge-0/0/3 up up
ge-0/0/3.0 up up eth-switch
ge-0/0/4 up down
ge-0/0/5 up up
ge-0/0/5.0 up up eth-switch
ge-0/0/6 up down
ge-0/0/7 up down
ge-0/0/8 up down
ge-0/0/9 up down
ge-0/0/10 up down
ge-0/0/11 up down
 
root@host:RE:0% cli show interface terse | grep inet
bme0.32768 up up inet 128.0.0.1/2
lo0.0 up up inet
vlan.0 up up inet
vlan.804 up up inet 10.127.1.32/24
vme.0 up up inet 10.85.33.208/24
 
root@host:RE:0% cli show interface terse | match inet
match: Command not found.
cli: remote side unexpectedly closed connection
 

Note: The above failure example points out the use of the pipe command with grep , but with match . Include double quotes as shown below:

root@:RE:0% cli show interface terse "|" match inet
bme0.32768 up up inet 128.0.0.1/2
bme0.36862 up up inet 128.0.0.1/2
me0.0 up up inet 10.93.40.67/21

 

Modification History

2020-05-19: Article reviewed for accuracy; added a point that the flexibility of command usage lies with both root and non-root users; article accurate and valid