Skip to content

Instantly share code, notes, and snippets.

@h1k3r
Created June 25, 2014 19:52
Show Gist options
  • Save h1k3r/089d43771bdf811eefe8 to your computer and use it in GitHub Desktop.
Save h1k3r/089d43771bdf811eefe8 to your computer and use it in GitHub Desktop.
Lua - get hostname
local _M = {}
function _M.getHostname()
local f = io.popen ("/bin/hostname")
local hostname = f:read("*a") or ""
f:close()
hostname =string.gsub(hostname, "\n$", "")
return hostname
end
return _M
@erichowey
Copy link

Thank you for this!

@huwenbiao
Copy link

thanks

@erikLundstedt
Copy link

does this still work?

@sdx6
Copy link

sdx6 commented Sep 9, 2023

thank you :)

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