treid71
Technical User
- May 12, 2009
- 3
Hi all,
I'm having a bit of a problem with a regexp in a tcl script I'm *attempting* to write for my Cisco router.
Long story short, I'm trying to compare the numerical value of the output against a threshold/variable I have set and the script just doesn't want to work. Here is the error I am receiving:
Register event failed:missing close-brace
while compiling
"foreach line [split $output "\n"]"
Here is the section of the script I am having a problem with. I want to extract the "-80" portion of the output and compare it (>=) against the threshold I have set of -75. Many thanks in advance, I have been pulling my hair out on this.
# Setup commands
set command "show cellular 0/2/0 radio | inc RSSI"
# Sample output of above: Current RSSI(RSCP) = -80 dBm
# Pull RSSI stats from router via CLI
set output [run_cli [list $command]]
# Pull out dBm with a regular expression
foreach line [split $output "\n"] {
if { [regexp {.*Current RSSI.* = (.*?)\} $line -> currentdBm] }
if { $currentdBm >= $rssi_signal_threshold }
action_syslog msg "Current RSSI on Cellular 0/2/0 is $currentdBm and has exceeded $rssi_signal_threshold"
}
I'm having a bit of a problem with a regexp in a tcl script I'm *attempting* to write for my Cisco router.
Long story short, I'm trying to compare the numerical value of the output against a threshold/variable I have set and the script just doesn't want to work. Here is the error I am receiving:
Register event failed:missing close-brace
while compiling
"foreach line [split $output "\n"]"
Here is the section of the script I am having a problem with. I want to extract the "-80" portion of the output and compare it (>=) against the threshold I have set of -75. Many thanks in advance, I have been pulling my hair out on this.
# Setup commands
set command "show cellular 0/2/0 radio | inc RSSI"
# Sample output of above: Current RSSI(RSCP) = -80 dBm
# Pull RSSI stats from router via CLI
set output [run_cli [list $command]]
# Pull out dBm with a regular expression
foreach line [split $output "\n"] {
if { [regexp {.*Current RSSI.* = (.*?)\} $line -> currentdBm] }
if { $currentdBm >= $rssi_signal_threshold }
action_syslog msg "Current RSSI on Cellular 0/2/0 is $currentdBm and has exceeded $rssi_signal_threshold"
}