lua-users home
lua-l archive

[Date Prev][Date Next][Thread Prev][Thread Next] [Date Index] [Thread Index]


I'll insert my obligatory plug for the "ex" API:
http://lua-users.org/wiki/ExtensionProposal

-- if you just want the exit code:
local exitcode = assert( os.spawn"my_command" ):wait()

-- if you want the output too:
local i,o = io.pipe()
local proc = assert(os.spawn{"my_command", stdout=o})
o:close()
local output = i:read"*a"
local exitcode = proc:wait()
i:close()

The above can and should be abstracted into a popen-ish function.  See
the wiki page for another example.

    -Mark