NX-OS Management–CLI Variables

Just discover this while going through the Cisco configuration guide “NX Fundamentals Configuration Guide” under the Chapter “Understanding the Command Line” at section “Configuring CLI Variables”.

What you can do is define persistent or non persistent variable to work with ! The persistent aspect depends if you configure the variable at EXEC or CONFIG modes.

By default there is two persistent variables defined :

N7K-2A# show cli variables

VSH Variable List (* = session vars)




You can call the variables like this :

N7K-2A# echo $(TIMESTAMP)



And of course you can use these as variables in other commands like this :

N7K-2A# copy running-config $(SWITCHNAME)_$(TIMESTAMP)

Copy complete, now saving to disk (please wait)…

N7K-2A# dir

       2330    Feb 13 18:53:12 2013  N7K-2A_2013-02-13-18.53.11

Custom variables can then be defined. If the variables is defined at CONFIG mode, the variables will be persistent :

N7K-2A(config)# cli var name OVERLAY1 overlay1

N7K-2A(config)# interface $(OVERLAY1)

N7K-2A(config-if-overlay)# sh run interface $(OVERLAY1)


!Command: show running-config interface Overlay1

!Time: Wed Feb 13 18:57:35 2013


version 5.2(1)


interface Overlay1

  otv control-group

  otv data-group

  otv extend-vlan 100

  no shutdown

This opens new ways of managing the device on the CLI but also with scripting as the NXOS supports Python.

Leave a Reply

Your email address will not be published. Required fields are marked *