Solved

Using variables in "alias" definition in exshrc.xsf

  • 30 July 2019
  • 4 replies
  • 106 views

Userlevel 1
Hi!

We want to define aliases using the script exshrc.xsf that is run every time a user logs in. Simple aliases are OK, but we want to create a variable with the most interesting ports and base aliases off that variable, like this:

set var PORTS "1:1,1:2,1:3"
alias shp "show port $PORTS inf"

After logging in, this won't work, but if I run the script using the run script command, it works as intended:

Slot-1 VPEX d123c.1 # shp
^
%% Invalid slot number detected at '^' marker.
%% Parse error in alias command definition.
Slot-1 VPEX d123c.2 # alias
alias shp='show port $PORTS inf'
Slot-1 VPEX d123c.3 # run script exshrc.xsf
Slot-1 VPEX d123c.4 # alias
alias shp='show port 1:1,1:2,1:3 inf'
Slot-1 VPEX d123c.5 #

Does anyone have a suggestion on how to make this work upon login and auto-execution of the exshrx.xsf?

/Fredrik

PS this is on an X590-24x-1q-2c running EXOS 30.2, but should be the same in any modern EXOS (21.x or above).
icon

Best answer by FredrikB 16 August 2019, 17:52

Hi Drew!

I opened a case (01897234 if you want to have a look) and was recommended the "enable cli scripting permanent" command, but I found that changing the exshrc.xsf script to this worked as I wanted:

enable cli scripting
set var PORTS "1:1,1:2,1:3"
alias shp "show port $PORTS inf"
alias shprx "show port $PORTS rxerrors no-refresh"

The main use for this function is to list only ports that are relevant in 40 and 100 G switches like the X870. When not using any break-out cables, every 3 of 4 interfaces will always be down and setting the $PORTS variable to 1,5,9,13 and so on gives me the opportunity to use commands that never list the "not present" ports all the time.

/Fredrik
View original

4 replies

Userlevel 1
Ok, replying to my own question... I found a rather ugly solution. From exshrc.xsf, I simply call another script, in this case I called it aliases.xsf. In there, I could define the aliases:

exshrc.xsf:
run script aliases.xsf

aliases.xsf:
set var PORTS "1:1,1:2,1:3"
alias shp "show port $PORTS inf"
alias shprx "show port $PORTS rxerrors no-refresh"

If anyone has an idea on how to make this work in the exshrc file, I'd appreciate some input!

/Fredrik
Userlevel 7
Hi @FredrikB,
Would you mind opening a case with GTAC so this behavior can be reviewed by Engineering? It sounds like the order of operations is a little off on the execution of the exshrc.xsf script.
Userlevel 1
Hi Drew!

I opened a case (01897234 if you want to have a look) and was recommended the "enable cli scripting permanent" command, but I found that changing the exshrc.xsf script to this worked as I wanted:

enable cli scripting
set var PORTS "1:1,1:2,1:3"
alias shp "show port $PORTS inf"
alias shprx "show port $PORTS rxerrors no-refresh"

The main use for this function is to list only ports that are relevant in 40 and 100 G switches like the X870. When not using any break-out cables, every 3 of 4 interfaces will always be down and setting the $PORTS variable to 1,5,9,13 and so on gives me the opportunity to use commands that never list the "not present" ports all the time.

/Fredrik
Userlevel 7
That answer makes sense to me. Glad the team was able to point you in the right direction.
Thanks for coming back to post the update!

Reply