cancel
Showing results forĀ 
Search instead forĀ 
Did you mean:Ā 
cancel
1872
Views
0
Helpful
2
Replies

How to output multiple _cli_results in one email

ciantwohig
Level 1
Level 1

When you call an action cli in EEM , the output generated from the last cli command is stored in the variable $_cli_result, the issue is this is overwritten each time action cli is written. 

So if I have two cli commands I want the output for ( i've made the event a config change so its easier to test)

event manager applet mail_cfg_chg
event syslog pattern ".*%SYS-5-CONFIG_I.*"
action 1.0 info type routername
action 1.1 cli command "enable"
action 1.2 cli command "show ip bgp sum | append cat4000_flash:test.txt"
action 1.3 cli command "show ip int brief | append cat4000_flash:test.txt"
action 1.4 syslog msg "*** BGP and int Brief ***"
action 1.6 cli command "more cat4000_flash:test.txt"
action 1.8 syslog msg "*** test log ***"
action 1.9 mail server "$_Email_Server" to "$_Email_To" from "$_Email_From" subject ": $_info_routername" body "$_cli_result"
!

I've tried to do this by appending to a new file in a valid new file in the flash , append output to that file and then call the output afterwards.

I get the following error 

%Error opening cat4000_flash:test.txt (No such file or directory)

I can't seem to see how to create a txt file , any suggestions?

2 Replies 2

Joe Clarke
Cisco Employee
Cisco Employee

Chances are the cat4000_flash: file system does not support "append".  You can test this by running those commands manually.

If you need to get the output of two commands, use the append action:

action 1.11 set result ""

action 1.21 append result $_cli_result

action 1.31 append result $_cli_result

Then use $result.  This requires EEM 3.0 or higher.

kirandeep.singh
Level 1
Level 1

is it possible to call _cli_result in one of the action cli commands?