Skip to content

Instantly share code, notes, and snippets.

@dedayoa
Forked from h1k3r/hostname.lua
Created August 23, 2018 11:10
Show Gist options
  • Save dedayoa/d0941cfb2dad72550250899d075893f0 to your computer and use it in GitHub Desktop.
Save dedayoa/d0941cfb2dad72550250899d075893f0 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
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment