[Date Prev][Date Next][Thread Prev][Thread Next]
[Date Index]
[Thread Index]
- Subject: Re: Lua / shell - How to "pipe" commands in os.execute() ?
- From: "Mark Edgar" <medgar123@...>
- Date: Wed, 4 Apr 2007 15:51:06 -0700
I'll insert my obligatory plug for the "ex" API:
http://lua-users.org/wiki/ExtensionProposal
-- if you just want the exit code:
local exitcode = assert( os.spawn"my_command" ):wait()
-- if you want the output too:
local i,o = io.pipe()
local proc = assert(os.spawn{"my_command", stdout=o})
o:close()
local output = i:read"*a"
local exitcode = proc:wait()
i:close()
The above can and should be abstracted into a popen-ish function. See
the wiki page for another example.
-Mark