In my Lua program i have to catch output from an external program. This external program needs certain environment variables. So i do this:
e = ""
e = e .. "A=100;"
e = e .. "B=Hi;"
e = e .. "C=Test;"
file = io.popen(e .. "/bin/aprogr")
Obviously the argument for popen() may pass the limit (if any) if the environment is large.
Is there any other way to pass the environment to the external program ?
There is an
os.spawn
function in the ExtensionProposal API.You can use it as follows:
lua-ex-pai provides implementations for POSIX and Windows.
You can find precompiled binaries of this implementation bundled with the LuaForWindows distribution.
Here is a more concise version of your use case: