TCL Script that triggers commands if MAC Address matches

  • 0
  • 2
  • Problem
  • Updated 5 months ago
  • (Edited)
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. 


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.

# @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 8)
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
configure ports $EVENT.LOG_PARAM_0 display-string "EXN-AccessPoint"
set var CLI.OUT " "
create log entry "Unknown_device_connected_on_port_($EVENT.LOG_PARAM_0)"
Photo of Dominique Ehrlich

Dominique Ehrlich

  • 140 Points 100 badge 2x thumb

Posted 5 months ago

  • 0
  • 2

Be the first to post a reply!