On Fri, Jan 13, 2012 at 7:37 PM, Laurent FAILLIE <
[email protected]> wrote:
> In LUA, the only way I found to retrieve the output of a command is to use
> io.popen() then io.read() ... but in this case I'm loosing the return code.
In Lua 5.2, the `file:close` method for files returned by io.popen
will return the error code. [1] You can devise workarounds in 5.1
such as calling os.execute to invoke some command that writes the exit
code to a file, perhaps stdout. Or just re-implement io.popen like
5.2 does. There are also some third-party libraries with more
advanced, though less portable, process manipulation capabilities
(e.g.
on win32).
[1]
http://www.lua.org/manual/5.2/manual.html#pdf-file:close