blob: cb2794321481f037fedb0d6e2b938ea6d7d176c5 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
|
local shell_utils = {}
local temp_file_path = "/tmp/i3luacommandouput"
function shell_utils.get_output(command)
os.execute(command .. " > " .. temp_file_path .. " 2> " .. temp_file_path)
local file = io.open(temp_file_path, "r")
if file == nil then
error("Can't read output.")
end
local output = file:read()
file:close()
return output or ""
end
return shell_utils
|