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 while untill the other process give some feed back. my requirement basically behaves like pipe in shell and tcl expect, or pexpect in python, and my question is, does lua provide such feature?
i've considered a little lua's coroutine but it cannot yield during the middle of executing a shell script, so i did not dig.
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 aio.popen()
ed process: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.