diff options
author | Steven Barth <steven@midlink.org> | 2008-03-30 19:25:31 +0000 |
---|---|---|
committer | Steven Barth <steven@midlink.org> | 2008-03-30 19:25:31 +0000 |
commit | 1bf67dcd798e6edc859e74c77b194928d7f63fbe (patch) | |
tree | 8df67a3ac9228a72daac8149d16c075ad9686038 /src/ffluci/sys.lua | |
parent | 9b4e269bea4db2e75d3d33757a53d2ab89bf05bf (diff) |
* Moved exec, execl from ffluci.util to ffluci.sys
* Introduced stub for ffluci.model.ipkg
Diffstat (limited to 'src/ffluci/sys.lua')
-rw-r--r-- | src/ffluci/sys.lua | 25 |
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")() |