11-22-2013 07:20 AM
I have an EEM applet that executes a show command using regex that works fine. However, when I converted the applet to TCL, I am having some problems with it. It's throwing an error on the line below:
if [catch {cli_exec $cli1(fd) "sh run | section ip prefix-list [^ ]+ seq 5 permit $ip_prefix\.0\/24"} _cli_result] {
error $_cli_result $errorInfo
}
TCL seems to be catching the [^ ] part of the show command and trying a substitution (trying to execute "^ " as a separate command). I could surround the show command with { } brackets but then $ip_prefix won't be substituted for the variable value. Is there any way of executing this show command within TCL? Thanks.
Solved! Go to Solution.
11-22-2013 10:48 AM
C819G-4G-V-K9#tclsh
C819G-4G-V-K9(tcl)#set ip_prefix 10.10.10
10.10.10
C819G-4G-V-K9(tcl)#sh run | section ip prefix-list [^ ]+ seq 5 permit $ip_prefix\.0\/24
invalid command name "^" ^
% Invalid input detected at '^' marker.
This works:
C819G-4G-V-K9(tcl)#sh run | section ip prefix-list \[\^ \]+ seq 5 permit $ip_prefix\.0\/24
ip prefix-list test seq 5 permit 10.10.10.0/24
11-22-2013 10:48 AM
C819G-4G-V-K9#tclsh
C819G-4G-V-K9(tcl)#set ip_prefix 10.10.10
10.10.10
C819G-4G-V-K9(tcl)#sh run | section ip prefix-list [^ ]+ seq 5 permit $ip_prefix\.0\/24
invalid command name "^" ^
% Invalid input detected at '^' marker.
This works:
C819G-4G-V-K9(tcl)#sh run | section ip prefix-list \[\^ \]+ seq 5 permit $ip_prefix\.0\/24
ip prefix-list test seq 5 permit 10.10.10.0/24
Discover and save your favorite ideas. Come back to expert answers, step-by-step guides, recent topics, and more.
New here? Get started with these tips. How to use Community New member guide