cancel
Showing results for 
Search instead for 
Did you mean: 

TCL Script that triggers commands if MAC Address matches

TCL Script that triggers commands if MAC Address matches

Dominique_Ehrli
New Contributor II
Hi Folks,
I've written a TCL script that looks for a specific MAC OUI in the FDB table and triggers certain commands if a match has been found.

The issue with this script is that I want to set a specific "Port Profile". These "Port Profiles" are deployed from the NetSight. The Script looks for "IMP_AccessPoints" and returns the number of the line where it found the term. Ever since I deleted some of the "Port Profiles" in NetSight the line number isn't equal to the PID anymore.

e.g.

1 - Guest
2 - WAN
5 - IMP_AccessPoints

So my Script would return the number "3" instead of 5. Can someone help me out? Maybe someone has an idea how to fix my script.

#MAC OUI
#@VariableFieldLabel "MAC OUI Number 1 (xx:xx:xx:)"

set var MAC1 d8:84:66:
set var myWaitVar $TCL(after [expr 2000 * 6])
set var CLI.OUT " "
show fdb ports $EVENT.LOG_PARAM_0 | include Default
set var list1 $TCL(split ${CLI.OUT})
set var list2 $TCL(string range $(list1) 0 😎
if (!$match($list2, $MAC1)) then
set var CLI.OUT " "
show edp ports $EVENT.LOG_PARAM_0
set var edp1 $TCL(split ${CLI.OUT} \n)
set var range1 $TCL(string range $(edp1) 235 270)
set var edp2 $TCL(regexp ${EVENT.LOG_PARAM_0} $(range1))
create log entry "($edp2)"
if ($edp2 == 0) then
clear netlogin state port $EVENT.LOG_PARAM_0
disable netlogin ports $EVENT.LOG_PARAM_0 dot1x web-based mac
set var CLI.OUT " "
show policy profile
set var pol1 $TCL(split ${CLI.OUT} \n)
set var pol2 $TCL(lsearch -regexp $pol1 {IMP_AccessPoints})
set var polport $pol2
configure policy rule admin-profile port $EVENT.LOG_PARAM_0 port-string $EVENT.LOG_PARAM_0 admin-pid $polport
create log entry "NETLOGIN_DISABLED_PASSED"
configure ports $EVENT.LOG_PARAM_0 display-string "EXN-AccessPoint"
create log entry "DISPLAY_STRING_COMMAND_PASSED"
set var CLI.OUT " "
else
endif
else
create log entry "Unknown_device_connected_on_port_($EVENT.LOG_PARAM_0)"
endif
0 REPLIES 0
GTM-P2G8KFN