Logic Machine Forum
Getting the MAC of your Logic Machine. - Printable Version

+- Logic Machine Forum (https://forum.logicmachine.net)
+-- Forum: LogicMachine eco-system (https://forum.logicmachine.net/forumdisplay.php?fid=1)
+--- Forum: Scripting (https://forum.logicmachine.net/forumdisplay.php?fid=8)
+--- Thread: Getting the MAC of your Logic Machine. (/showthread.php?tid=22)



Getting the MAC of your Logic Machine. - rocfusion - 07.07.2015

Hi,

The following code will allow you retrieve the MAC address of your Logic Machine.  Whether this is useful, to some, anyway here it is

Thanks,

Roger

Code:
local f = io.popen('ifconfig')
local t = f:read()
f:close()
local mac = t:match("HWaddr ([%:%x]*)") 

alert(mac)



RE: Getting the MAC of your Logic Machine. - admin - 08.07.2015

There's a faster way Smile


Code:
mac = io.readfile('/sys/class/net/eth0/address'):trim()



RE: Getting the MAC of your Logic Machine. - rocfusion - 08.07.2015

Yep I knew that one, that works on the presence that 'eth0' always exists.


RE: Getting the MAC of your Logic Machine. - admin - 08.07.2015

Ethernet is physically present on all devices. If you need some kind of identification, you can also get unique CPU ID by reading "/proc/device-tree/uniqid"