Question

EXOS CLI script - handover arguments


Userlevel 6
Hi,

i want to create a simple script that restart poe power on a specific port:

code:
# restart inline-power via CLI
# usage: run script restart-poe ARG1 #=Port-Number
enable cli scripting
disable inline-power port $ARG1
enable inline-power port $ARG1
save config
yes


If i run the script on EXOS 22.6 i get this error:

code:
TEST-SW.2 # run script restart-poe.xsf 1
Error in script "restart-poe.xsf", line 4
%% Unrecognized command: "disable inline-power port $ARG1"
%% Invalid port number detected.
Error in script "restart-poe.xsf", line 5
%% Unrecognized command: "enable inline-power port $ARG1"
%% Invalid port number detected.
Error in script "restart-poe.xsf", line 7
%% Unrecognized command: "yes"
%% Invalid input detected.
TEST-SW.3 #


How can i hand over the argument of the script (which is the port number) correctly to my script ?!

Thanks.

3 replies

Userlevel 6
Looking at the vars after running a script it seems you need to use variable CLI.ARGC or CLI.ARGV1.

X460-48t.3 # run script test 1
X460-48t.4 #
X460-48t.4 #
X460-48t.4 # show var
----------------------------------------
Count : 7
----------------------------------------

------------------------------------------------------------------
variableName variableValue
-------------------------------- --------------------------------
CLI.ARGC 1
CLI.ARGV0 test
CLI.ARGV1 1
CLI.SCRIPT_TIME_REMAINING 0
CLI.SESSION_TYPE serial
CLI.USER admin
STATUS 0
-------------------------------------------------


enable cli scripting
show var CLI.ARGV1

X460-48t.10 # run script test var1
var1
X460-48t.11 #
Userlevel 6
Thanks Oscar - i modify - seems to work - but not reliable.

Is there a command to hold or sleep for 2 seconds between disable and enable?


code:
# restart inline-power via CLI
# usage: run script restart-poe X or Y:X
enable cli scripting
disable inline-power port $CLI.ARGV1
enable inline-power port $CLI.ARGV1
save config
Userlevel 6
Yes, just add a var that executes the TCL wait.

set var wait $TCL(wait 10000)

Above line will wait 10 seconds (10000 msec).

Reply