author | Mikael Berthe <mikael@lilotux.net> |
Sat, 24 Apr 2010 10:45:00 +0200 | |
changeset 39 | 237af42156a1 |
parent 3 | 508108deee63 |
child 66 | d9c00a9fe9d5 |
permissions | -rw-r--r-- |
3 | 1 |
|
2 |
function shcmd (cmd) |
|
3 |
if not cmd or cmd == "" then return nil, "No command" end |
|
4 |
||
5 |
local fullcmd = cmd.." 2> /dev/null" |
|
6 |
local fh = io.popen(fullcmd) |
|
7 |
result = fh:read("*a") -- read cmd output |
|
8 |
fh:close() |
|
39
237af42156a1
Add checks after shcmd() calls
Mikael Berthe <mikael@lilotux.net>
parents:
3
diff
changeset
|
9 |
if not result then return nil end |
3 | 10 |
-- Trim trailing newlines |
11 |
local r = result:gsub("\n+$", "") |
|
12 |
return r |
|
13 |
end |