lua-users home
lua-l archive

[Date Prev][Date Next][Thread Prev][Thread Next] [Date Index] [Thread Index]


I use NearlyFreeSpeach from time to time, and it has Lua as standard.

This little test script dumps the various CGI env vars (try for
example http://rtraschke.nfshost.com/luatest.cgi/foobar?foo&bar=baz ):

$ cat luatest.cgi
#!/usr/local/bin/lua-5.1
io.stdout:write("Content-Type: text/plain\r\n\r\n")
io.stdout:write("Hello, world! (Lua)\r\n")
for k, v in pairs(arg) do
        io.stdout:write(tostring(k), ": ", tostring(v), "\r\n")
end
io.stdout:write("PATH=" .. os.getenv("PATH") .. "\r\n")
vars = { 'SERVER_SOFTWARE', 'SERVER_NAME', 'GATEWAY_INTERFACE',
        'SERVER_PROTOCOL', 'SERVER_PORT', 'REQUEST_METHOD',
        'PATH_INFO', 'PATH_TRANSLATED', 'SCRIPT_NAME',
        'QUERY_STRING', 'REMOTE_HOST', 'REMOTE_ADDR',
        'AUTH_TYPE', 'REMOTE_USER', 'REMOTE_IDENT',
        'CONTENT_TYPE', 'CONTENT_LENGTH', 'HTTP_USER_AGENT',
}
for _, e in ipairs(vars) do
        io.stdout:write(e .. "=" .. os.getenv(e).. "\r\n")
end