如何使用Lua运行可执行文件?

Bri*_*nan 21 lua executable

我有一个可执行文件我想用Lua运行...我该怎么做?

似乎无法找到任何关于此的文档.

小智 40

您可以使用Lua的本机"执行"命令.

例:

os.execute("c:\\temp\\program.exe")
Run Code Online (Sandbox Code Playgroud)

来源:Lua Guide/os.execute


Dou*_*rie 15

如果您需要程序的输出,请使用 io.popen


Ren*_*tra 6

对于需要使用 io.popen 的人

local openPop = assert(io.popen('/bin/ls -la', 'r'))
local output = openPop:read('*all')
openPop:close()
print(output) -- > Prints the output of the command.
Run Code Online (Sandbox Code Playgroud)