cancel
Showing results for 
Search instead for 
Did you mean: 

TCL Script to read from line and input in another line

TCL Script to read from line and input in another line

Ahmed_Haroun
New Contributor III
what i am trying to automate is simple, but i have little knowledge about TCL.

1- issue the following command:

show configuration netlogin.

2- match the underlined part from the below output of the previous command:

* Slot-1 # sh conf "netlogin"
#
# Module netLogin configuration.
#
configure netlogin vlan temp
enable netlogin dot1x mac web-based
configure netlogin authentication protocol-order dot1x mac web-based
configure netlogin add mac-list ff:ff:ff:ff:ff:ff 48
enable netlogin ports 1:1-15,1:17-18,1:20-38,1:43-45,2:3-24,2:28,2:30,2:36-38,2:43-45 dot1x
enable netlogin ports 1:16,1:35-40,1:43-45,2:35-38,2:40,2:43-45 mac
configure netlogin dot1x ports 1:1 timers server-timeout 3 reauth-period 0 reauthentication off
configure netlogin dot1x ports 1:2 timers server-timeout 3 reauth-period 0 reauthentication off

3- input the above in the below command

configure upm event user-authenticate profile printer ports **HERE**

4- save.

please notice that i want to match only dot1x ports, not the mac.

thanks in advance.
2 REPLIES 2

Ahmed_Haroun
New Contributor III
Thanks Nikolay , That is great.

Necheporenko__N
Extreme Employee
Hello Ahmed,

The following script returns ports list as an variable
enable cli scripting disable clipaging set var cli.out 0 sh conf "netlogin" | i enable set var ss $TCL(split ${cli.out} "\n") set var sline $TCL(lsearch -glob $ss *ports*dot1x*) set var sline $TCL(lindex $ss $sline) set var sline $TCL(regexp -all -inline {\S+} $sline) set var result $TCL(lindex $sline 3) show var result

Example:
* Slot-1 Stack.38 # set var cli.out 0
* Slot-1 Stack.39 # sh conf "netlogin" | i enable
ss $TCL(split ${cli.out} "\n")
set var sline $TCL(lsearch -glob $ss *ports*dot1x*)
set var sline $TCL(lindex $ss $sline)
set var sline $TCL(regexp -all -inline {\S+} $sline)
set var result $TCL(lindex $sline 3)
show var resultenable netlogin dot1x mac web-based
enable netlogin ports 1:10-20,2:30,2:35-44 dot1x
enable netlogin ports 2:1-10 mac
* Slot-1 Stack.40 # set var ss $TCL(split ${cli.out} "\n")
* Slot-1 Stack.41 # set var sline $TCL(lsearch -glob $ss *ports*dot1x*)
* Slot-1 Stack.42 # set var sline $TCL(lindex $ss $sline)
* Slot-1 Stack.43 # set var sline $TCL(regexp -all -inline {\S+} $sline)
* Slot-1 Stack.44 # set var result $TCL(lindex $sline 3)
* Slot-1 Stack.45 # show var result
1:10-20,2:30,2:35-44
* Slot-1 Stack.46 #
* Slot-1 Stack.46 #
Best Regards,
Nikolay

GTM-P2G8KFN