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:

-- 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})
local output = i:read"*a"
local exitcode = proc:wait()

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