Per the lawyers:
Any scripts that are written and posted on the Hub are provided “AS IS” with no warranty or representation as to its use. Any use should be carefully considered and be validated by the user. These scripts, regardless of who writes them, assume that the user accepts all of the risk and responsibility, and are not provided pursuant to any authorized services or professional services entitlement or obligation by Extreme Networks, its subsidiaries, agents or licensors. In no event shall the poster nor Extreme Networks be responsible for the functionality of the script nor are we responsible for any outages or network issues caused by use or integration of the script, including any degradation of functionality of Extreme products or technology. It is strongly recommended that any use of scripts or other technical information posted on this site must be validated before use in any production network by the user of the script.
With that said:
#@MetaDataStart#@DetailDescriptionStart
###############################################################################
#@DetailDescriptionEnd
enable cli scripting
disable cli-config-logging
disable clipaging
create log entry "**********Starting CLI Script**********"
###############################################################################
#@ScriptDescription "Short Script Description"
#@VariableFieldLabel "When this script encounters errors, do you wish to abort or ignore (abort or ignore)"
set var ynCliModeAbortEnabled abort
#@SeparatorLine
# Begin custom variable definitations
# set var addOrDelete $CLI.ARGV1
set var addOrDelete 1
# End of custom variable definitations
#@MetaDataEnd
###############################################################################
# CONFIGURATION DETAIL
###############################################################################
# ERROR HANDLING
###############################################################################
if (!$match($ynCliModeAbortEnabled,ignore)) then
create log entry "CLI mode set for Ignore on error"
configure cli mode scripting ignore-error
else
create log entry "CLI mode set for abort on error"
configure cli mode scripting abort-on-error
endif
###############################################################################
# Start of CLI Script (Enter the custom script code below)
###############################################################################
set var CLI.OUT " "
show edp ports all
set var inputA $TCL(list ${CLI.OUT})
set var listA $TCL(split $inputA "\n")
set var countA $TCL(llength $listA)
set var icountBack ($countA - 0)
set var icount 0
#
#
while ($icount < $icountBack) do
set var findIt $TCL(lindex $listA $icount)
set var findTrunkPorts $TCL(regexp {(?![0-9:]+\s+)([A-Za-z0-9._+-]+\s+)([0-9:]+\s+)([0-9:]+\s+)([0-9]+\s+)([0-9]+\s+)} $findIt)
set var findEnd $TCL(regexp {configure\sqosprofile} $findIt)
#
if ($findTrunkPorts == 1) then
set var vlanNameOnly $TCL(regexp -inline {(?![0-9:]+\s+)([A-Za-z0-9._+-]+\s+)([0-9:]+\s+)([0-9:]+\s+)([0-9]+\s+)([0-9]+\s+)} $findIt)
set var value0 $TCL(lindex $vlanNameOnly 0)
set var value1 $TCL(lindex $vlanNameOnly 1)
set var value3 $TCL(lindex $vlanNameOnly 3)
if ($addOrDelete == 1) then
configure ports $(value0) display-string Trunk_$(value1)_$(value3)
endif
if ($addOrDelete == 0) then
create log entry "NO TURUNK PORTS"
endif
endif
#
if ($findEnd == 1) then
set var icount ($icountBack)
endif
set var icount ($icount + 1)
endwhile
#
if ($VAREXISTS(CLI.OUT)) then
delete var CLI.OUT
endif
if ($VAREXISTS(inputA)) then
delete var inputA
endif
if ($VAREXISTS(listA)) then
delete var listA
endif
if ($VAREXISTS(countA)) then
delete var countA
endif
if ($VAREXISTS(icount)) then
delete var icount
endif
if ($VAREXISTS(findEnd)) then
delete var findEnd
endif
if ($VAREXISTS(findIt)) then
delete var findIt
endif
if ($VAREXISTS(icountBack)) then
delete var icountBack
endif
if ($VAREXISTS(value0)) then
delete var value0
endif
if ($VAREXISTS(value1)) then
delete var value1
endif
if ($VAREXISTS(value3)) then
delete var value3
endif
if ($VAREXISTS(vlanNameOnly)) then
delete var vlanNameOnly
endif
if ($VAREXISTS(findTrunkPorts)) then
delete var findTrunkPorts
endif
if ($VAREXISTS(printCommand)) then
delete var printCommand
endif
if ($VAREXISTS(addOrDelete)) then
delete var addOrDelete
endif
if ($VAREXISTS(ynCliModeAbortEnabled)) then
delete var ynCliModeAbortEnabled
endif
###############################################################################
# End of CLI Script
###############################################################################
create log entry "**********Finshed running CLI Script**********"
enable clipaging
disable cli-config-logging
disable cli scripting