[Date Prev][Date Next][Thread Prev][Thread Next]
[Date Index]
[Thread Index]
- Subject: Re: catching stderror & stdout
- From: Luiz Henrique de Figueiredo <lhf@...>
- Date: Tue, 20 Jul 1999 01:32:59 -0300 (EST)
>From lua-l@tecgraf.puc-rio.br Tue Jul 20 01:02:31 1999
>From: Pablo Saldo <ec4pas@super.furg.br>
>How can I catch the outputs from stderror and stdout in Lua? I mean
>redirecting them to a variable or such a thing.
You might redefine 'write' to save all output into a variable.
Something like
OUT=""
function write(...)
foreachi(arg, function (i,v) OUT=OUT..v end
end
Not the fastest code in the world, but it works.
For a faster solution, you could store in OUT a table of strings.
Otherwise, I guess you'd have to change liolib.c.
--lhf