randomguy Posted December 30, 2016 Posted December 30, 2016 Using ruby's built-in CGI class, I've tried to capture and use query string parameters. approach 1:cgi = CGI.newparams = cgi.params approach 2:cgi = CGI.newparams = CGI.parse cgi.query_string Both of these are working ok on my pc, but not on helio JOHNNY server. Could anyone explain, why is it not working? How can I use query string in my script? Thanks.
Krydos Posted December 30, 2016 Posted December 30, 2016 Is that https://ruby-doc.org/stdlib-1.9.3/libdoc/cgi/rdoc/CGI.html#method-c-parse what you're trying to do?
randomguy Posted December 30, 2016 Author Posted December 30, 2016 @Krydos this is exactly what I am trying to do with approach 2, after approach 1 failed to deliver.
Krydos Posted December 30, 2016 Posted December 30, 2016 How about: #!/usr/bin/ruby require "cgi" cgi_request = CGI::new("html5") puts "Content-Type: text/html\n\n" puts query = cgi_request.query_string puts "query:<br />" puts "#{query}<br /><br />" params = CGI::parse(query) puts "params:<br />" p params http://krydos1.heliohost.org/cgi-bin/query.rb?hello=world&goodbye=thanksforallthefish
randomguy Posted December 31, 2016 Author Posted December 31, 2016 Thanks @Krydos your code is working.
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now