I am new to Python and I need to write code that contains a directory containing files with random names, for example:
JuniperAccessLog-stand-alone-FCL_VPN-20120319-1110.gz
JuniperAccessLog-stand-alone-FCL_VPN-20120321-1110.gz
I need to get a more recent file
I try this, but to no avail.
import os from datetime import datetime t = datetime.now() archive = t.strftime("JuniperAccessLog-standalone-FCL_VPN-%Y%m%d-%H*.gz") file = os.popen(archive)
Result:
sh: JuniperAccessLog-standalone-FCL_VPN-20120320-10*.gz: command not found
is it possible to use this logic?
source share