Search Members Help

» Welcome Guest
[ Log In :: Register ]

Mini-ITX Boards Sale, Fanless BareBones Mini-ITX, Bootable 1G DSL USBs, 533MHz Fanless PC <-- SALE $200 each!
Get The Official Damn Small Linux Book. DSL Market , Great VPS hosting provided by Tektonic
Pages: (2) </ [1] 2 >/

[ Track this topic :: Email this topic :: Print this topic ]

reply to topic new topic new poll
Topic: lighttpd lua query string access< Next Oldest | Next Newest >
humpty Offline





Group: Members
Posts: 655
Joined: Sep. 2005
Posted: April 01 2008,16:20 QUOTE

anyone familiar with lighttpd using lua scripts ?

i'm trying to call a lua script by supplying a query string in a link ;

e.g
<a href="goto_date.lua?31-3-2008">1</a>

but don't know how to get to the query string argument(s)

arg[0] only holds the program path
arg[1] is nil

how do i get the date ?  ???
Back to top
Profile PM 
lucky13 Offline





Group: Members
Posts: 1478
Joined: Feb. 2007
Posted: April 01 2008,16:43 QUOTE

Not sure I understand if this is based on user input or parsing some date variable. Try this yet?
http://www.lua.org/pil/22.1.html


--------------
"It felt kind of like having a pitbull terrier on my rear end."
-- meo (copyright(c)2008, all rights reserved)
Back to top
Profile PM WEB 
mikshaw Offline





Group: Members
Posts: 4856
Joined: July 2004
Posted: April 01 2008,16:51 QUOTE

It's an environment variable

Try os.getenv("QUERY_STRING")

Here's an example I have in one of my in-progress cgi scripts
Code Sample
-- break up query string
params=" "..string.gsub(os.getenv("QUERY_STRING"),"&"," ").." "

function get_param(var)
local p=string.gsub(params,".*"..var.."=(.-)%s.*","%1")
-- strip any naughty leading path
p=string.gsub(p,".*/","")
return(p)
end

var_a=get_param("one")
var_b=get_param("two")


This particular function breaks up a string that uses the format
myscript.cgi?one=something&two=somethingelse
The lua script would end up setting var_a="something" and var_b="somethingelse"


--------------
http://www.tldp.org/LDP/intro-linux/html/index.html
Back to top
Profile PM WEB 
humpty Offline





Group: Members
Posts: 655
Joined: Sep. 2005
Posted: April 02 2008,01:42 QUOTE

tks mikshaw, that's just what i was looking for.
Back to top
Profile PM 
roberts Offline





Group: Members
Posts: 4983
Joined: Oct. 2003
Posted: April 03 2008,19:51 QUOTE

mikshaw wrote:
Quote
Here's an example I have in one of my in-progress cgi scripts


Just curious, did the existing cgi.lua not work for you?

We have had cgi.lua together with sample lua scripts for monkey webserver since before murgaLua.
Back to top
Profile PM WEB 
6 replies since April 01 2008,16:20 < Next Oldest | Next Newest >

[ Track this topic :: Email this topic :: Print this topic ]

Pages: (2) </ [1] 2 >/
reply to topic new topic new poll
Quick Reply: lighttpd lua query string access

Do you wish to enable your signature for this post?
Do you wish to enable emoticons for this post?
Track this topic
View All Emoticons
View iB Code