Skip to content

Latest commit

 

History

History
25 lines (17 loc) · 465 Bytes

README.md

File metadata and controls

25 lines (17 loc) · 465 Bytes

Get/set hostname from lua

Simple ffi wrapper over gethostname(2) and sethostname(2)

local hostname = require 'hostname'

-- Simple get hostname

print("My hostname is", hostname())
-- my.example.com

-- Module interface

print("My hostname is", hostname.get())
-- my.example.com

print("My short host is", hostname.host())
-- my

-- Set hostname into name
local name = "newhost"
hostname.set(name)
-- If something went wrong, error will be raised