В ExtensionProposal API есть функция os.spawn
.
Вы можете использовать ее следующим образом:
require"ex"
local proc, err = os.spawn{
command = e.."/bin/aprogr",
args = {
"arg1",
"arg2",
-- etc
},
env = {
A = 100, -- I assume it tostrings the value
B = "Hi",
C = "Test",
},
-- you can also specify stdin, stdout, and stderr
-- see the proposal page for more info
}
if not proc then
error("Failed to aprogrinate! "..tostring(err))
end
-- if you want to wait for the process to finish:
local exitcode = proc:wait()
lua-ex-pai предоставляет реализации для POSIX и Windows.
Вы можете найти предварительно скомпилированные двоичные файлы этой реализации в комплекте с LuaForWindows .
Вот более краткая версияВаш вариант использования:
require"ex"
local file = io.pipe()
local proc = assert(os.spawn(e.."/bin/aprogr", {
env={ A = 100, B = "Hi", C = "Test" },
stdout = file,
}))
-- write to file as you wish