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

Filter month and date from "show clock" command

ozzman1009
Level 1
Level 1

I would like to import part of the "show clock" command for a python script. Is there a way to filter just the month and day?

 

for example:

R1#show clock
21:45:35.891 TIME Sat Sep 1 2018

 

would resolve to: 

Sep 1

2 Replies 2

balaji.bandi
Hall of Fame
Hall of Fame

I use awk to get the results as show in below example :

 

embed the code in to python script and tweak as per the needs

 

# cat bb.txt
21:45:35.891 TIME Sat Sep 1 2018
# cat bb.txt | awk '{$1=""; print $4, $5, $6}';
Sep 1 2018

BB

***** Rate All Helpful Responses *****

How to Ask The Cisco Community for Help

Do you have any suggestions on which python module might be able to interpret that command?

It appears the your first step would be to save or redirect the output to a text file then read the file from a system that understands the recommended commands. 

My previous attempts to cat and awk break python, due to limitations of the module I was using, and this appears to be more of a BASH solution. Have you successfully executed this solution in Python?  

Review Cisco Networking for a $25 gift card