XOS: How to create CLI aliases / shortcuts ?

  • 1
  • 2
  • Question
  • Updated 5 months ago
  • Answered
Is it possible to create command shortcuts for commands which are often used or cumbersome to type in ? Like other major vendors "alias exec scn show cdp neighbor" ?
I guess with recent XOS the scripting feature should make this possible.

If someone use this - it is very welcome.

Regards
Photo of M.Nees

M.Nees, Embassador

  • 9,262 Points 5k badge 2x thumb

Posted 3 years ago

  • 1
  • 2
Photo of Stephen Williams

Stephen Williams, Employee

  • 8,950 Points 5k badge 2x thumb
You can do it in python or cli scripting , but you would still need to type "load script cdp" to execute the command if the script file was cdp.py or cdp.xsf

Is that what your looking for?
(Edited)
Photo of M.Nees

M.Nees, Embassador

  • 9,262 Points 5k badge 2x thumb
OK. Scripting will help me with long commands. Is it possible to commit parameter to the script ?
 
And what about when i will create a shortcut for fewer command typing ? Like for example "sln" for show lldp neighbors ?

Regards
Photo of Brandon Clay

Brandon Clay, Escalation Support Engineer

  • 13,244 Points 10k badge 2x thumb
Hi  Matthias,

You can pass CLI arguments to scripts. You can find an example of this with a Python script here:
https://github.com/extremenetworks/ExtremeScripting/blob/master/EXOS/Python/watch/watch.py

-Brandon
Photo of Frank

Frank

  • 3,722 Points 3k badge 2x thumb
Something like that would definitely be a "nice to have"; I could alias "save" to "wr" for my cisco-centric cow-orkers :)
Photo of M.Nees

M.Nees, Embassador

  • 9,262 Points 5k badge 2x thumb
Review after 2 years!

Since EXOS V22.3 we have the needed command:

https://documentation.extremenetworks.com/exos_22.4/exos_21_1/exos_commands_all/r_alias.shtml

Regards
Photo of Drew C.

Drew C., Community Manager

  • 38,276 Points 20k badge 2x thumb
Completely forgot about this topic. Glad you found it and brought it back to life :)
Photo of Dave Hammers

Dave Hammers, Dir SW Engineering

  • 3,502 Points 3k badge 2x thumb
EXOS 22.3 and later can store commands like 'alias' in a exshrc.xsf script on a switch. This script is run after a successful login, Similar concept to the linux .bashrc file after a linux login.

This is a way to make aliases available to any login by storing the alias commands in this file.

exshrc.xsf is stored in /usr/local/cfg

Because this is a .xsf file and follows the EXOS .xsf scripting rules, the exshrc.xsf file can be any script you would like to run after a login is successful.
(Edited)
Photo of M.Nees

M.Nees, Embassador

  • 9,262 Points 5k badge 2x thumb
Hi Dave,

that is a very very interesting advice not only regarding to aliases.
There a lot of possible use cases.

(This works well ...)

Thanks for emphasing that!

Regards,
Matthias
Photo of Drew C.

Drew C., Community Manager

  • 38,494 Points 20k badge 2x thumb
I was asked to come up with some other use cases for exshrc.xsf besides aliases.

I could see this being use for setting session-specific variables.
disable clipaging and configure cli are good examples.

What other ideas does the community have?
(Edited)