Summary
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)
See Also ...
Lua functions
os.clock - Amount of elapsed/CPU time used (depending on OS)
os.date - Formats a date/time string
os.difftime - Calculates a time difference in seconds
os.exit - Attempts to terminate the process
os.getenv - Returns an operating system environment variable
os.remove - Deletes a file
os.rename - Renames a file
os.setlocale - Sets the current locale to the supplied locale
os.time - Returns the current time or calculates the time in seconds from a table
os.tmpname - Returns a name for a temporary file
Topics
Lua base functions
Lua bc (big number) functions
Lua bit manipulation functions
Lua coroutine functions
Lua debug functions
Lua io functions
Lua math functions
Lua os functions
Lua package functions
Lua PCRE regular expression functions
Lua script extensions
Lua string functions
Lua syntax
Lua table functions
Lua utilities
Scripting
Scripting callbacks - plugins
(Help topic: lua=os.execute)