cancel
Showing results for 
Search instead for 
Did you mean: 
cancel
1621
Views
5
Helpful
1
Replies

EEM Script : Copy cli_result on file

Maurizio Bau
Level 1
Level 1

Hi all

I need to be save "show ip int bri | ex down" and other similar show command on a single file without using TCL ( i have 7609 with SRD5 IOS)

I read in other post that can't possibile to manage a "douBle pipe"

NOT WORKING
action 1.0 cli command "show ip int bri | ex down | append sup-bootdisk:interface.txt"

I try to use a following script like this discussion https://supportforums.cisco.com/thread/2101880, but i don't have any file on sup-bootdisk

EEM Script

event manager applet showproc

event timer watchdog time 20

action 1.0 cli command "enable"

action 1.1 cli command "show process cpu | ex 0.00"

action 1.2 cli command "more $_cli_result | APPEND sup-bootdisk:showproc.txt"

What's my error?

Thanks

Maurizio Baù

1 Reply 1

Joe Clarke
Cisco Employee
Cisco Employee

This applet will not work.  The "more" command only works with files.  No, you cannot do double pipes with applets.

You could move to Tcl to do the filtering you want:

::cisco::eem::event_register_timer watchdog time 20

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 proc cpu | exc 0.00"} _cli_result] {
    error $_cli_result $errorInfo
}

set fd [open "sup-bootdisk:showproc.txt" a]
puts $fd $_cli_result
close $fd


# Close open cli before exit.
catch {cli_close $cli1(fd) $cli1(tty_id)} result