Get Hardware (Mac) Address through Applescript

Hi All,

How can I get Hardware (Mac) Address using applescript. Please tell me how can I do it. I have searched in the dictionary but I found nothing there.

Why I need it, I have developed some tool for InDesign & Quark User. I want to add the mentioned module in my application, so that as user will run the tool it will first validate the Hardware address, and if it match then application will run otherwise it will show a piracy message.

Thanks
Rajeev

G5, Mac OS X (10.4.2)

Posted on Dec 6, 2006 8:15 PM

Reply
6 replies

Dec 6, 2006 8:35 PM in response to rajeev kumar1

There are several ways of doing it. Querying System Profiler is one of them, or you can use any of a number of shell commands, such as:

<pre class=command>do shell script "ipconfig getifaddr en0"</pre>

Note that this command will fail if the interface isn't configured/up. You could use:

<pre class=command>do shell script "ifconfig en0"</pre> and parse the results for the 'ether' line.

Dec 6, 2006 11:33 PM in response to rajeev kumar1

>get if addr en0 failed, (os/kern) failure

Then you don't have an active interface. You can't use ipconfig to query an interface that isn't up.

You need to decide how you want to deal with this - you won't know in advance what interfaces the user may have active. For this reason, relying on the MAC address is inherently problematic. You might be better off using the system's serial number (which is less likely to change anyway):

<pre class=command>set serialNum to do shell script "system_profiler SPHardwareDataType| awk -F: '/Serial/ {print $2}'"</pre>

This thread has been closed by the system or the community team. You may vote for any posts you find helpful, or search the Community for additional answers.

Get Hardware (Mac) Address through Applescript

Welcome to Apple Support Community
A forum where Apple customers help each other with their products. Get started with your Apple Account.