27

I have an executable I want to run using Lua ... how do I do this?

Can't seem to find any documentation anywhere about this.

Brian T Hannan
  • 3,925
  • 18
  • 56
  • 96

4 Answers4

53

You can use Lua's native 'execute' command.

Example:

os.execute("c:\\temp\\program.exe")

Sources: Lua Guide / os.execute

Judge Maygarden
  • 26,961
  • 9
  • 82
  • 99
Anthony M. Powers
  • 1,257
  • 9
  • 10
23

If you need the output of the program, use io.popen

Doug Currie
  • 40,708
  • 1
  • 95
  • 119
5

Use os.execute.

interjay
  • 107,303
  • 21
  • 270
  • 254
4

For someone who need using 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.
Rendy Saputra
  • 161
  • 1
  • 4