Created
February 27, 2011 04:24
-
-
Save Packetslave/845900 to your computer and use it in GitHub Desktop.
Get the lease expiration on MacOS X
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/python | |
from datetime import datetime, timedelta | |
import os, plistlib | |
pl = plistlib.readPlist('/var/db/dhcpclient/leases' + "/" + \ | |
os.listdir('/var/db/dhcpclient/leases')[0]) | |
print "Lease expires: %s" % (pl['LeaseStartDate'] + \ | |
timedelta(seconds=pl['LeaseLength'])) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment