KNOWLEDGE BASE
Log In    |    Knowledge Base    |    4D Home
Tech Tip: How to get the MAC address
PRODUCT: 4D | VERSION: 11.5 | PLATFORM: Mac & Win
Published On: December 3, 2009

The Media Access Control address (MAC address) is a networking term that refers to the unique identifier assigned to network adapters or Network Interface Cards. Among other things, a MAC address allows computers to uniquely identify themselves on a network. So it is useful to have this information, especially for networking purposes.

You can obtain the MAC address using the LAUNCH EXTERNAL PROCESS command and certain Unix/MS-DOS commands. You will need to parse through the results though, as each Unix/MS-DOS command returns the MAC address differently.

Here is a simple method designed to find and return the MAC address for Windows OS or Mac OS:

C_LONGINT($OS)
C_TEXT($macAddress;$cmd;$input;$output;$error)

PLATFORM PROPERTIES($OS)

If ($OS=Mac OS )
   $cmd:="system_profiler SPHardwareDataType"
   LAUNCH EXTERNAL PROCESS($cmd;$input;$output;$error)
   $macAddress:=Substring($output;Position("Serial Number:";$output)+14;12)
Else
   $cmd:="ipconfig /all"
   LAUNCH EXTERNAL PROCESS($cmd;$input;$output;$error)
   $macAddress:=Substring($output;Position("Physical Address";$output)+36;17)
End if

ALERT("Your MAC address is "+$macAddress)

Commented by Milan Adamov on March 6, 2017 at 7:08 AM
New selectior is SPNetworkDataType
Commented by David Fisher-Fleming on January 29, 2010 at 10:01 AM
This works for Mac OS X 10.5.8:

$cmd:="ifconfig en0"
LAUNCH EXTERNAL PROCESS($cmd;$input;$output;$error)
$macAddress:=Substring($output;Position("en0";$output)+77;17)
Commented by Guy Algot on December 4, 2009 at 1:18 PM
The line... cmd:="system_profiler SPHardwareDataType" ... does not return the MAC address when using Mac OS X 10.5.8