So i want to write an EEM that basically starts a seperate script where i check what user is logged on, to which group it belongs and then define if they can or cannot run the command. Example:
event manager applet FILTERCMD
event cli pattern "^interface GigabitEthernet1/0/[0-9]+$" sync yes
action 001 cli command "enable"
action 002 cli command "tclsh flash:/filtercmd.tcl $_cli_cmd"
action 003 set _exit_status "$_cli_result"
So here, i want to run filtercmd.tcl with the exact command entered as a variable. In my example i used $_clie_cmd as a placeholder. What im looking for is the correct variable to achieve my goal. Once the TCL script has run it will either return 0 (prevent the command from running) or return 1 (allow the command to run). The variable $_cli_result contains the output after running the tcl script.
So basically if user A loggs in and issues
interface GigabitEthernet1/0/2
he is allowed to run the command, but if user B loggs in and issues the same command, it is getting blocked. Another use case, if user A tries to run a different interface like:
interface GigabitEthernet1/0/19
we may want to block it, even though we allowed interface Gi1/0/2.
So im not looking for any content for filtercmd.tcl, i only want to know how to get the exact command entered into an argument for calling the filtercmd.tcl script.
I have tried to realize this with an event manager policy but the scripts there are running in a safe-tcl environment and are very slow. It takes over 700ms to just get the output of the show users wide command. And i plan on doing a whole lot more than that. So i dont want to have a 3s lag every time i try to enter a command.