i have some shell scripts those printing some message to stdout, and i want to spawn some other process if output matches some regexp, i may also want to hang the shell for a wh
Sadly, Lua doesn't provide piping support out of the box, so you'll have to choose between reading and writing. The closest you can get is by iterating through the :lines() of a io.popen()ed process:
for line in io.popen('/some/other/process'):lines() do
-- previous line will block until output is available
if line:match '^some regex' then
-- match found! do some stuff
end
end -- EOF reached
If you have access to C modules, luaposix provides an interface to pipe()
throughposix.pipe()
However, bear in mind Lua may not be the most appropriate tool for the job. IMHO you'll be better off using TCL or Python, or even a bash script.