09-01-2018 01:49 PM - edited 03-08-2019 04:03 PM
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
09-02-2018 12:52 AM
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
09-02-2018 08:50 AM
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?
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