To interact with other programs on the system and perform actions
that are not directly supported by lua, one can delecate the action
to the operating system shell with |
|
|
local success = os.execute('mkdir -p /tmp/example') if success then print('successfully created directory') end |
|
local handle = io.popen("date --date='@2147483647'") if handle == nil then return end local stdout = handle:read() success = handle:close() if success then print('output is:', stdout) else print('error when executing command') end |
$ lua execing-processes.lua successfully created directory output is: Tue Jan 19 03:14:07 UTC 2038 |
Next example: Exit.