Hi All,
I am new to tcl script. Below is the script which I tried to reset connections.
The scripts works but I have got an issue in repeating the action same action until tracking status changes.
This script change the interface IP address whenever the tracking status changes to ""DOWN. I look for some assistance to repeat same action changing interface IP address at certain interval until the tracking status changes to "UP".
Please let me know if you can review the script & help me. Thanks in advance.
Here is the complete script:
::cisco::eem::event_register_track 1 state down
namespace import ::cisco::eem::*
namespace import ::cisco::lib::*
array set arr_einfo [event_reqinfo]
if [catch {cli_open} result] {
error $result $errorInfo
} else {
array set cli1 $result
}
if [catch {cli_exec $cli1(fd) "enable"} _cli_result] {
error $_cli_result $errorInfo
}
if [catch {cli_exec $cli1(fd) " show ip int brief | ex unass|Lo|Tu|unset|down"} _cli_result] {
error $_cli_result $errorInfo
}
foreach {line} "$_cli_result" {
set _regexp_result [regexp {([0-9]+\.)([0-9]+\.)([0-9]+\.)([0-9]+)} $line]
if {$_regexp_result == "1"} {
puts "$line"
if {$line == "192.168.100.8"} {
if [catch {cli_exec $cli1(fd) "config t"} _cli_result] {
error $_cli_result $errorInfo
}
if [catch {cli_exec $cli1(fd) "int FastEthernet4"} _cli_result] {
error $_cli_result $errorInfo
}
if [catch {cli_exec $cli1(fd) "ip address 192.168.100.6 255.255.255.0"} _cli_result] {
error $_cli_result $errorInfo
}
if [catch {cli_exec $cli1(fd) "end"} _cli_result] {
error $_cli_result $errorInfo
}
} else {
if [catch {cli_exec $cli1(fd) "config t"} _cli_result] {
error $_cli_result $errorInfo
}
if [catch {cli_exec $cli1(fd) "int FastEthernet4"} _cli_result] {
error $_cli_result $errorInfo
}
if [catch {cli_exec $cli1(fd) "ip address 192.168.100.8 255.255.255.0"} _cli_result] {
error $_cli_result $errorInfo
}
if [catch {cli_exec $cli1(fd) "end"} _cli_result] {
error $_cli_result $errorInfo
}
}
}
# Close open cli before exit.
catch {cli_close $cli1(fd) $cli1(tty_id)} result
}