lua-users home
lua-l archive

[Date Prev][Date Next][Thread Prev][Thread Next] [Date Index] [Thread Index]



It's not portable, Mac doesn' have the proc interface.

On Thu, Mar 18, 2010 at 2:43 PM, Petr Štetiar <ynezz@true.cz> wrote:

function mac(iface)
       if not iface then
               return nil, 'no interface'
       end

       local f = io.open('/proc/net/arp', 'r')
       if not f then
               return nil, 'open error'
       end

       local match = string.format('%%x*:.*%s', iface)
       local mac = string.match(tostring(f:read('*a')), match)
       if mac then return mac:sub(1, 17), nil end
end

print(mac("eth0"))