30

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.

asked May 13, 2010 at 18:50

4 Answers 4

57

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

Example:

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

Sources: Lua Guide / os.execute

Judge Maygarden
27.7k9 gold badges86 silver badges101 bronze badges
answered May 13, 2010 at 18:56
2
  • Nearly double-posted with interjay! Ha! At least we both said the same thing! Cheers. Commented May 13, 2010 at 18:57
  • Thank you for a clear and simple example that demonstrates the concept in a way that can be easily grasped immediately upon inspection. Commented Feb 4, 2014 at 21:05
23

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

answered May 14, 2010 at 2:21
9

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.
answered Sep 21, 2021 at 0:57
5

Use os.execute.

answered May 13, 2010 at 18:56
0

Your Answer

Draft saved
Draft discarded

Sign up or log in

Sign up using Google
Sign up using Email and Password

Post as a guest

Required, but never shown

Post as a guest

Required, but never shown

By clicking "Post Your Answer", you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.