os.execute

Executes an operating system command

Prototype

status = os.execute (command)

Description

Passes 'command' to the operating system shell for execution. Returns a status code.

status = os.execute ("dir") --> (directory listing whizzes by)
Here is a method of capturing the output to a file, and reading it in:

-- get a temporary file name
n = os.tmpname ()

-- execute a command
os.execute ("dir > " .. n)

-- display output
for line in io.lines (n) do
  print (line)
end

-- remove temporary file
os.remove (n)

Lua functions

Topics