Translated uname.php and uptime.php to Lua.

This commit is contained in:
Johannes Findeisen 2024-03-15 06:12:43 +01:00
commit 1713577e62
4 changed files with 51 additions and 2 deletions

22
uptime/uptime.lua Normal file
View file

@ -0,0 +1,22 @@
---
permalink: /cgi/uptime/index.lua
---
-- Function to execute shell commands
local function shell_exec(command)
local handle = io.popen(command)
local result = handle:read("*a")
handle:close()
return result
end
-- Execute shell commands
local uptime = shell_exec('uptime')
local version = shell_exec('uptime -V')
-- Output the HTTP header
io.write("Content-Type: text/plain; charset=utf-8\r\n\r\n")
-- Output the result
io.write('Server ' .. version:sub(1, -2) .. ': ' .. uptime)