lua-users home
lua-l archive

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

>From Tue Jul 20 01:02:31 1999
>From: Pablo Saldo <>

>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


  function write(...)
	  foreachi(arg, function (i,v) OUT=OUT..v 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.