Knowledge Center Search


 

EX Switches - How to execute CLI commands from within the Shell

  [KB15939] Show KB Properties

  [KB15939] Hide KB Properties

Categories:
Knowledge Base ID: KB15939
Last Updated: 28 Apr 2011
Version: 2.0

Summary:
How to execute CLI commands from within the Shell

Problem or Goal:
This article provides a method for executing CLI commands from the Shell. 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 Shell.

Solution:
There is an "alias", or shortcut command, that allows the user to execute CLI commands from the shell prompt.  This is useful when troubleshooting or monitoring while in Shell.

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

root@hots: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", please 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

Purpose:
Implementation

Related Links:

 

 

ASK THE KB

Question or KB ID:


 


 

 
Copyright© 1999-2012 Juniper Networks, Inc. All rights reserved.