11-28-2022 12:03 PM
I have the following EEM scripts:
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
The above EEM scripts append the lines in 1.3 to a file called report.txt. My issue is that the data is not getting written to a new line. It is just getting added to the same line and is making the file hard to read and manage. How Can I set this up so the data from 1.3 is appended to the file as a new line?
Solved! Go to Solution.
12-02-2022 07:00 AM
I figured it out. I can't believe it was this simple. I changed it from "write" to "puts" and that solved everything.
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 puts 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 puts fh "\$_event_pub_time,DECTK Kit,DG4_ECK_03,is offline."
action 1.4 file close fh
Thanks for your guidance. Much appreciated.
11-28-2022 03:57 PM
not tried myself, just thought.
put $output
file open fh flash:report.txt a+
puts $fh $output
file close fh
11-30-2022 05:53 AM
Will the "puts $fh $output" line be an additional line to my script? Add it after the 1.3 line?
11-29-2022 06:29 AM
Add new line syntax to end of 1.3.
action 1.3 file write fh "\$_event_pub_time,DECTK Kit,DG4_ECK_03,is offline\n"
11-30-2022 05:50 AM
That's not working. All it does is add an "n" to the text.
11-30-2022 06:05 AM
\n works in 17.6.2 code. If you have a version where its not working then try the ascii value of carriage return \015.
action 1.3 file write fh "\$_event_pub_time,DECTK Kit,DG4_ECK_03,is offline \015"
11-30-2022 09:30 AM
Same issue as earlier. Just adds 015 to my text. I am on a 3925 router with IOS 15.7(3)M8. Are these variable you are having me add? I've tried many different variations of what you have shown me. Thanks for your help. I am so close to having this the way I want. This is the last piece.
12-01-2022 02:15 AM
Hello,
as far as I recall, the ASCII codes for form feed are 12, and for carriage return,13. You could try either \012 or \12, or \013, or \13.
12-02-2022 07:00 AM
I figured it out. I can't believe it was this simple. I changed it from "write" to "puts" and that solved everything.
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 puts 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 puts fh "\$_event_pub_time,DECTK Kit,DG4_ECK_03,is offline."
action 1.4 file close fh
Thanks for your guidance. Much appreciated.
12-03-2022 07:05 AM
glad you were able to figure it out - maybe I was not clear when I posted that was my suggestion. anyway all good.
Find answers to your questions by entering keywords or phrases in the Search bar above. New here? Use these resources to familiarize yourself with the community: