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

Parsing CLI output from "show clock"

miriamc
Level 1
Level 1

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?

2 Replies 2

Dan Frey
Cisco Employee
Cisco Employee

Ruben Cocheno
Spotlight
Spotlight

@miriamc 

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.

Tag me to follow up.
Please mark it as Helpful and/or Solution Accepted if that is the case. Thanks for making Engineering easy again.
Connect with me for more on Linkedin https://www.linkedin.com/in/rubencocheno/