summaryrefslogtreecommitdiffhomepage
path: root/src/ffluci/sys.lua
diff options
context:
space:
mode:
Diffstat (limited to 'src/ffluci/sys.lua')
-rw-r--r--src/ffluci/sys.lua25
1 files changed, 25 insertions, 0 deletions
diff --git a/src/ffluci/sys.lua b/src/ffluci/sys.lua
index 532324d4bd..367d41e8c1 100644
--- a/src/ffluci/sys.lua
+++ b/src/ffluci/sys.lua
@@ -27,6 +27,31 @@ limitations under the License.
module("ffluci.sys", package.seeall)
require("posix")
+-- Runs "command" and returns its output
+function exec(command)
+ local pp = io.popen(command)
+ local data = pp:read("*a")
+ pp:close()
+
+ return data
+end
+
+-- Runs "command" and returns its output as a array of lines
+function execl(command)
+ local pp = io.popen(command)
+ local line = ""
+ local data = {}
+
+ while true do
+ line = pp:read()
+ if (line == nil) then break end
+ table.insert(data, line)
+ end
+ pp:close()
+
+ return data
+end
+
-- Returns the hostname
function hostname()
return io.lines("/proc/sys/kernel/hostname")()