[c-nsp] Cisco IOS XR event manager run

Peter Rathlev peter at rathlev.dk
Tue Apr 7 04:02:14 EDT 2015


On Tue, 2015-04-07 at 10:46 +0300, Mohammad Khalil wrote:
> #Run cmds
> foreach cmd $commands {
>      action_syslog priority info msg "Executing: $cmd"
>      set result [ cli_exec $cli(fd) $cmd ]
>      action_syslog priority info msg $result }
> 
> RP/0/0/CPU0:XR1#event manager run test.tcl
> Tue Apr  7 13:43:44.488 EET
> RP/0/0/CPU0:Apr  7 13:43:45.768 : tclsh[65816]: %HA-HA_EEM-6-ACTION_SYSLOG_LOG_INFO : test.tcl: test.tcl was triggered
> RP/0/0/CPU0:Apr  7 13:43:45.768 : tclsh[65816]: %HA-HA_EEM-5-ACTION_SYSLOG_LOG_NOTICE : test.tcl: Opening CLI...
> RP/0/0/CPU0:Apr  7 13:43:47.318 : tclsh[65816]: %HA-HA_EEM-6-ACTION_SYSLOG_LOG_INFO : test.tcl: OK
> RP/0/0/CPU0:Apr  7 13:43:47.318 : tclsh[65816]: %HA-HA_EEM-6-ACTION_SYSLOG_LOG_INFO : test.tcl: Executing: sh bgp summary
> RP/0/0/CPU0:Apr  7 13:43:48.048 : tclsh[65816]: %HA-HA_EEM-6-ACTION_SYSLOG_LOG_INFO : test.tcl: sh bgp summary
> 
> No output appears

Actually, some output appeared. It seems the first line of $result,
which is the command itself, is echoed back to you. So it's probably
because action_syslog doesn't handle multi-line messages.

You could try splitting the result:

foreach cmd $commands {
  action_syslog priority info msg "Executing: $cmd"
  set result_lines [ split [ cli_exec $cli(fd) $cmd ] "\n" ]
  foreach line $result_lines {
    action_syslog priority info msg $line
  }
}

-- 
Peter





More information about the cisco-nsp mailing list