lua-users home
lua-l archive

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


> For dumping the MAC Address, call os.execute ('ifconfig | grep HWaddr > [FILENAME]'). Then use io.open,
> read, close to get the > info from the file into a lua string, then os.remove (to delete the file) and
> strings functions find (search for 'HWaddr ')  and sub to extract the MAC info 

You could also use a more straight forward way (not using a temporary file): 

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