05-28-2024 01:01 AM
I have an EEM applet that runs the "show clock" command, then tried to parse the output using the "action string range" statement. I wanted to get the 2 digit hour and 2 digit minute into two seperate varaibles. So I used something like: action xxx string range $_cli_result 0 1 action xxx set hour $_string_result action xxx string range $_cli_result 3 4 action xxx set minute $_string result This didn't work however, as there appear to be some non-printing/control characters at the front of the string that caued the "string range" indexing not to work properly. In fact I couldn't get it to return the tens digit of the hour at all, I just kept getting what appeared on the screen as a blank character. Does anyone know what's going on with the "show clock" command output?
06-01-2024 05:27 PM - edited 06-01-2024 05:27 PM
@Georg Pauwen shows how to parse the fields from show clock in this post.
https://community.cisco.com/t5/network-management/time-refernce-for-event-pub-sec/td-p/5117454
06-04-2024 05:39 AM
EEM aligns with TCL and the event_pub_time grabs this info from gettime() in linux. IOS-XE cli massages gettime() to a user configurable timezone if required but his does not change the underlying linux OS function. If you want the time to get reported by the specific timezone configured I believe you are on the right track by issuing "show clock" and the info can be parsed out by regexp rather than a string command.
Discover and save your favorite ideas. Come back to expert answers, step-by-step guides, recent topics, and more.
New here? Get started with these tips. How to use Community New member guide