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

27

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

好像无法在任何地方找到相关文档。

4个回答

54
你可以使用Lua的本地'execute'命令。
例子:
os.execute("c:\\temp\\program.exe")

来源:Lua指南 / os.execute


几乎和 interjay 重复发帖!哈!至少我们都说了同样的话!干杯。 - Anthony M. Powers
感谢您提供一个清晰简单的示例,以一种可以立即理解的方式演示了这个概念。 - User.1

23
如果需要程序输出,可以使用 io.popen

5

如果你需要使用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.

5

网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接