Mac OS X Tips

This page provides the way to obtain MAC address (hardware address) of the wireless network interface on Mac OS X with AppleScript.

Search from the Internet:
Custom Search

Obtaining wireless network interface's hardware address on Mac OS X

Wireless network administrators sometimes try to request users to provide wireless network interface's hardware address for their operation such as debugging. Administrators can find your wireless network interface's hardware address (MAC address) on Mac OS X by some ways (e.g., using ifconfig command), but average users may not know the way, or they sometimes wrongly provide wired network interface's one.

The following AppleScript code provides the way to show the wireless network interface's hardware address by GUI to Mac OS X users. Note that the wireless interface name had been changed between 10.6 and 10.7, so this script tries to check the version first.

-- Obtain the product version of Mac OS X (X.X format from X.X.X format by "cut" command)
set OSVer to do shell script "sw_vers -productVersion  | cut -f1-2 -d." as string

if OSVer is equal to "10.5" or OSVer is equal to "10.6" then
  -- For Leopard, and Snow Leopard
  set theResult to do shell script "networksetup -getmacaddress AirPort | awk '{print $3}'" as string
  display dialog "Your MAC address (Wi-Fi):" default answer theResult buttons ("OK")
else if OSVer is equal to "10.7" then
  -- For Lion
  set theResult to do shell script "networksetup -getmacaddress Wi-Fi | awk '{print $3}'" as string
  display dialog "Your MAC address (Wi-Fi):" default answer theResult buttons ("OK")
else
  -- Display an error dialog
  display dialog "Unsupported version of Mac OS X: " & OSVer
end if