I had this code in another thread, but it was a bit hard to find, so I'll put it here in the Lua section.
Here is an example of executing an operating system command, and capturing the output.
Here is an example of executing an operating system command, and capturing the output.
-- 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)