From 1713577e628d65c096dada7fe3a8bd4d9e06e9d3 Mon Sep 17 00:00:00 2001 From: Johannes Findeisen Date: Fri, 15 Mar 2024 06:12:43 +0100 Subject: [PATCH] Translated uname.php and uptime.php to Lua. --- uname/uname.lua | 27 +++++++++++++++++++++++++++ uname/uname.php | 2 +- uptime/uptime.lua | 22 ++++++++++++++++++++++ uptime/uptime.php | 2 +- 4 files changed, 51 insertions(+), 2 deletions(-) create mode 100644 uname/uname.lua create mode 100644 uptime/uptime.lua diff --git a/uname/uname.lua b/uname/uname.lua new file mode 100644 index 0000000..05f143b --- /dev/null +++ b/uname/uname.lua @@ -0,0 +1,27 @@ +--- +permalink: /cgi/uname/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 command +local uname = shell_exec('uname -mrs') + +-- Find position of the first occurrence of a substring in a string +local pos = string.find(uname, '-', 1, true) + +-- Extract substring +local res = string.sub(uname, 1, pos - 1) + +-- Output the HTTP header +io.write("Content-Type: text/plain; charset=utf-8\r\n\r\n") + +-- Output the result +io.write(res) + diff --git a/uname/uname.php b/uname/uname.php index 2ab056f..a264dc9 100644 --- a/uname/uname.php +++ b/uname/uname.php @@ -1,5 +1,5 @@ --- -permalink: /cgi/uname/ +permalink: /cgi/uname/obsolete.php ---