cancel
Showing results for 
Search instead for 
Did you mean: 

Using variables in "alias" definition in exshrc.xsf

Using variables in "alias" definition in exshrc.xsf

FredrikB
Contributor II
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).
1 ACCEPTED SOLUTION

FredrikB
Contributor II
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 solution in original post

4 REPLIES 4

Drew_C
Valued Contributor III
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!

FredrikB
Contributor II
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

Drew_C
Valued Contributor III
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.

FredrikB
Contributor II
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
GTM-P2G8KFN