I\'d like to do the equivalent of:
foo=$(echo \"$foo\"|someprogram)
within lua -- ie, I\'ve got a variable containing a bunch of text, and
There is nothing in the Lua standard library to allow this.
Here is an in-depth exploration of the difficulties of doing bidirectional communication properly, and a proposed solution:
if possible, redirect one end of the stream (input or output) to a file. I.e.:
fp = io.popen("foo >/tmp/unique", "w") fp:write(anything) fp:close() fp = io.open("/tmp/unique") x = read("*a") fp:close()
You may be interested in this extension which adds functions to the os
and io
namespaces to make bidirectional communication with a subprocess possible.