# An error is thrown if no matching service is found. # If `addr` is an empty string or a missing value, the current primary IPv4 address is used. # the address is bound to (class `network service` is defined in `Sytem Events.sdef`). # Given (one of) the local system's IPv4 address(es), returns the network service object whose interface Set nameOfServiceWithPrimaryIpv4Address to name of serviceWithPrimaryIpv4Address Set serviceWithPrimaryIpv4Address to my networkServiceByIp4Address("") # Obtain the `service` instance underlying the Thus, to determine the MAC address corresponding to the current IPv4 address, the solution below uses do shell script to parse the output from CLI ifconfig with help from awk.While IPv4 address of (system info) returns the current (primary) IPv4 address, sadly, primary Ethernet address of (system info) always returns the wired Ethernet interface's MAC address, which may or may not be the interface to which the current IPv4 address is bound.However, a service object's interface property contains a MAC address property. ![]() ![]() The services objects (from dictionary System Events.sdef) contains no information about currently bound addresses.Unfortunately, this is non-trivial, as the information must be drawn from several sources: ![]() This answer, by contrast, shows you how to determine the network service to whose interface the current (primary) IPv4 address is bound: Answer shows you how to obtain all active (read: not disabled) network services, whether currently bound to addresses or not.
0 Comments
Leave a Reply. |