Skip to content

Instantly share code, notes, and snippets.

@glarizza
Created October 19, 2010 00:01
Show Gist options
  • Save glarizza/633327 to your computer and use it in GitHub Desktop.
Save glarizza/633327 to your computer and use it in GitHub Desktop.
>>> store = SCDynamicStoreCreate(None, "global-network", None , None) >>> print store
<SCDynamicStore 0x104400f80 [0x7fff70174f20]> {server port = 0x369f, notification delivery not requested (yet)}
>>> print SCDynamicStoreCopyValue(store, None)
None
>>> print SCDynamicStoreCopyValue(store, "State:/Network/Global/IPv4")
{
PrimaryInterface = en0;
PrimaryService = "961CAB70-82E4-4781-8343-622FC8C81BB2";
Router = "10.13.0.1";
}
>>> print SCDynamicStoreCopyValue(store, "State:/Network/Interface/en1/IPv4")
{
Addresses = (
"10.13.0.190"
);
BroadcastAddresses = (
"10.13.0.255"
);
SubnetMasks = (
"255.255.255.0"
);
}
>>>
>>> gotit = SCDynamicStoreCopyValue(store, "State:/Network/Interface/en0/IPv4")
>>> print gotit['Addresses'][0]
10.13.0.191
>>> try:
... doit['Addresses'][0]
... except TypeError:
... print "didn't work"
...
didn't work
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment