mcbot/libs/shcmd.lua
author Mikael Berthe <mikael@lilotux.net>
Tue, 13 Apr 2010 21:07:41 +0200
changeset 3 508108deee63
child 39 237af42156a1
permissions -rw-r--r--
Add command xep


function shcmd (cmd)
    if not cmd or cmd == "" then return nil, "No command" end

    local fullcmd = cmd.." 2> /dev/null"
    local fh = io.popen(fullcmd)
    result = fh:read("*a")  -- read cmd output
    fh:close()
    -- Trim trailing newlines
    local r = result:gsub("\n+$", "")
    return r
end