- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-07-2022 08:31 AM
I am trying to create an output file and save it to flash. Here is what I want:
show log | i DECTK
But I want to redirect the results to a text file in flash. I realize I can use the redirect command, but I can only do that with the entire log. I only want specific log that I created using EEM. I also can't use the include and redirect command at the same time. Is there a way I can accomplish this?
Solved! Go to Solution.
- Labels:
-
Cisco Software
Accepted Solutions
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-02-2022 07:10 AM
I figured out my issue. In order to use the variable correctly, I needed to put either single quotes around the variable, or a back slash in front of it.
event manager applet 999_A trap authorization bypass
event track 999 state up
action 1.0 cli command "enable"
action 1.1 syslog priority warnings msg ",DECTK Kit,DG4_ECK_03,is online."
action 1.2 file open fh flash:report.txt a+
action 1.3 file write fh "\$_event_pub_time,DECTK Kit,DG4_ECK_03,is online."
action 1.4 file close fh
event manager applet 999_B trap authorization bypass
event track 999 state down
action 1.0 cli command "enable"
action 1.1 syslog priority warnings msg ",DECTK Kit,DG4_ECK_03,is offline."
action 1.2 file open fh flash:report.txt a+
action 1.3 file write fh "\$_event_pub_time,DECTK Kit,DG4_ECK_03,is offline."
action 1.4 file close fh
My final script. It works just as I want it to. Thanks for your guidance.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-07-2022 09:08 AM
just test as below :
event manager applet logtest authorization bypass
event none
action 1.0 cli command "enable"
action 1.1 set logcmd01 "show logging | in BULK"
action 1.2 cli command "$logcmd01"
action 1.3 file open lf flash:error.txt w
action 1.4 file write lf "$_cli_result"
action 1.5 file close lf
!
#event manager run logtest
1#more flash:error.txt
Jun 21 12:29:49.054: %EWLC_HA_LIB_MESSAGE-6-BULK_SYNC_STATE_INFO: Switch 2 R0/0: wncmgrd: INFO: Bulk sync status : COLD/n slot memory init failed for 1
Jun 21 12:32:37.785: %EWLC_HA_LIB_MESSAGE-6-BULK_SYNC_STATE_INFO: Switch 1 R0/0: wncmgrd: INFO: Bulk sync status : HOT
Jun 21 12:32:37.591: %EWLC_HA_LIB_MESSAGE-6-BULK_SYNC_STATE_INFO: Switch 2 R0/0: wncmgrd: INFO: Bulk sync status : HOT
Jun 21 12:32:45.428: %HA_CONFIG_SYNC-6-BULK_CFGSYNC_SUCCEED: Bulk Sync succeeded
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-07-2022 10:17 AM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-07-2022 10:23 AM
can you share EEM you used?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-07-2022 10:38 AM
event none
action 1.0 cli command "enable"
action 1.1 set logcmd01 "show logging | in DECTK"
action 1.2 cli command "$logcmd01"
action 1.3 file open lf flash:report.txt w
action 1.4 file write lf "$_cli_result"
action 1.5 file close lf
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-07-2022 12:51 PM
can you post show version from your device and model.
instead of pasting, type the syntax with? what option you get ?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-07-2022 01:05 PM
It's a Cisco 3925 router with version 15.7(3)M8.
After I type "action 1.4 file write lf" and hit the ? I have 1 option which is "WORD string data to write test".
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-07-2022 01:21 PM
i just tested on 15.2 IOS code as below :
WAN-DMZ(config-applet)#action 1.4 file write lf ?
WORD string data to write test
WAN-DMZ(config-applet)#action 1.4 file write lf "$_cli_result" ?
WORD 1 to 4294967295, or $variable
<cr>
WAN-DMZ(config-applet)#action 1.4 file write lf "$_cli_result"
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-08-2022 06:49 AM
My result:
HOSTNAME(config-applet)# action 1.4 file write lf $_cli_result
% Incomplete command
HOSTNAME(config-applet)# action 1.4 file write lf $_cli_result ?
WORD 1 to 4294967295, or $variable
It won't accept that line unless I put something after $_cli_result, but anything I put after it is what gets written to the report.txt file. After I do a show run, this is what the configs look like:
event manager applet report authorization bypass
event none
action 1.0 cli command "enable"
action 1.1 set logcmd01 "show log | in DECTK"
action 1.2 cli command ""
action 1.3 file open lf report.txt w
action 1.4 file write lf "TEST"
action 1.5 file close lf
It doesn't seem to be creating the $logcmd01 variable. Isn't there a command to enable the use of Linux commands in the IOS? Maybe I need to do that first.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-08-2022 08:18 AM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-08-2022 10:36 AM
HOSTNAME(config-applet)# action 1.4 file write lf "$_cli_result" <-- i seee the Quotes missing here
i would suggest to paster each line to see any errors.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-08-2022 11:00 AM
Results without quotes:
HOSTNAME(config-applet)# action 1.4 file write lf $_cli_result
% Incomplete command
Results with quotes:
HOSTNAME(config-applet)# action 1.4 file write lf "$_cli_result"
^
% Invalid input detected at '^' marker.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-08-2022 11:28 AM
Here are all the ways I have tried:
HOSTNAME(config)# event manager applet report authorization bypass
HOSTNAME(config-applet)# event none
HOSTNAME(config-applet)# action 1.0 cli command "enable"
HOSTNAME(config-applet)# action 1.1 set logcmd01 "show log | in DECTK"
HOSTNAME(config-applet)# action 1.2 cli command "$logcmd01"
HOSTNAME(config-applet)# action 1.3 file open fh report.txt w
HOSTNAME(config-applet)# action 1.4 file write fh $_cli_result
% Incomplete command
HOSTNAME(config-applet)# action 1.4 file write fh $_cli_result ?
WORD 1 to 4294967295, or $variable
<cr> <cr>
HOSTNAME(config)# event manager applet report authorization bypass
HOSTNAME(config-applet)# event none
HOSTNAME(config-applet)# action 1.0 cli command "enable"
HOSTNAME(config-applet)# action 1.1 set logcmd01 "show log | in DECTK"
HOSTNAME(config-applet)# action 1.2 cli command "$logcmd01"
HOSTNAME(config-applet)# action 1.3 file open fh report.txt w
HOSTNAME(config-applet)# action 1.4 file write fh "$_cli_result"
^
% Invalid input detected at '^' marker.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-08-2022 11:57 AM
I have virtual router with Version 15.7(3)M3 - it works as expected.
can you post :
#show event manager ver
Let me think any other ways like TCP script can help you.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-07-2022 10:44 AM
At the action "1.4 file write lf "$_cli_result"" line, I get an "Incomplete command" when I hit enter. I've tried working with that line but can't get anything to work.
