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
: 여기
은 사용 사례에 대한보다 간결 버전입니다