Skip to content

Instantly share code, notes, and snippets.

@Packetslave
Created February 27, 2011 04:24
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Packetslave/845900 to your computer and use it in GitHub Desktop.
Save Packetslave/845900 to your computer and use it in GitHub Desktop.
Get the lease expiration on MacOS X
#!/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