Header Only - DO NOT REMOVE - Extreme Networks

Script synax that waits on user input before committing changes?


Userlevel 1
We want to create a script that will do the following:

show port 5:2,6:1 info
Wait for user to answer if the ports shown are the correct ports to be disabled
If yes execute "disable port 5:2,6:1", then execute "save config"
If no abort

I haven't been able to find a tcl example that incorporates waiting for user input with a if/then.

6 replies

Userlevel 4
Hi Stephen,

I think you may be looking for the Built-In Function: $READ(prompt)

#Example:
set var CLI.OUT " "
show port 5:2, 6:1 information
show var CLI.OUT

set var answer $READ(Are these the correct ports to be disabled?)

#logic based on input
Userlevel 4
Or something like:

disable clip
set var ports "1,2"
set var cli.out 0
show ports $ports info detail
show var cli.out
set var ok $TCL(concat "Disable ports" $ports "? (yes/no)")
set var ok $READ($ok)
set var ok $TCL(string equal $ok "yes")
if $ok then
disable port $ports
save
endif
Userlevel 4
or something like:

disable clip
set var ports "1,2"
set var cli.out 0
show ports $ports info detail
show var cli.out
set var ok $TCL(concat "Disable ports" $ports "?")
show var ok
set var ok $READ(yes or no?)
set var t $TCL(string equal $ok "yes")
if $t then
disable port $ports
save
endif
Userlevel 1
Thanks! Any way we can also echo the saving progress without showing the rest of the code?
Userlevel 4
Well, not really the saving process... but I added the "show var cli.out" after the "save" line and below is that is the output.

disable clipset var ports "1,2"
set var cli.out 0
show ports $ports info detail
show var cli.out
set var ok $TCL(concat "Disable ports" $ports "?")
show var ok
set var ok $READ(yes or no?)
set var t $TCL(string equal $ok "yes")
if $t then
disable port $ports
save
show var cli.out
endif

....

Disable ports 1,2 ? yes or no?
yes
The configuration file primary.cfg already exists.
Saving configuration on master Node .. done!
Configuration saved to primary.cfg successfully.
Userlevel 1
Perfect! Thanks a lot!

Reply