Skip to content

Instantly share code, notes, and snippets.

What would you like to do?
Lua - get hostname
local _M = {}
function _M.getHostname()
local f = io.popen ("/bin/hostname")
local hostname = f:read("*a") or ""
hostname =string.gsub(hostname, "\n$", "")
return hostname
return _M
Copy link

erichowey commented Sep 11, 2015

Thank you for this!

Copy link

huwenbiao commented Dec 29, 2020


Copy link

erikLundstedt commented Dec 12, 2021

does this still work?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment