lua-users home
lua-l archive

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

On Fri, Jan 13, 2012 at 7:37 PM, Laurent FAILLIE <> wrote:
> In LUA, the only way I found to retrieve the output of a command is to use
> io.popen() then ... 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).