# -*- lua -*- # hello world # print a simple string on stdout print "Hello world" # argv # access command line parameters (no segmentation fault accepted, nor silent exception, so some languages must explicitly check the presence of the argument) print(arg[1]) # env # access environment variable print(getenv"HOME") # test file readable # return exit code error (non zero) if a file is not readable if not openfile("/etc/mtab", "r") then exit(1) end # formatting # print integers in a simple formatted string a=1; b=2; print(a .. " + " .. b .. " = " .. a + b) # system # call an external program and check the return value if execute "false" ~= 0 then _ALERT "false failed\n" end execute "echo done"