lua-users home
lua-l archive

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

On Thu, 21 Aug 2008 12:44:58 -0700
"Wesley Smith" <> wrote:

> Hi,
> Is there a pure lua way to redirect stdout back into Lua?  For example
> if I have the script:
> os.execute("pwd")
> Can I get the result of calling pwd back as a string in Lua?  If
> there's not a pure Lua way, are there any modules out there that
> redirect stdout?

If you have built your Lua appropriately, and on a platform that can
support it, you can use io.popen:

If not, and you don't want to have to resort to C, you'll have to get
your system's shell to redirect the output to a file, and then read it