randomguy Posted December 30, 2016 Share 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. Quote Link to comment Share on other sites More sharing options...
Krydos Posted December 30, 2016 Share 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? Quote Link to comment Share on other sites More sharing options...
randomguy Posted December 30, 2016 Author Share Posted December 30, 2016 @Krydos this is exactly what I am trying to do with approach 2, after approach 1 failed to deliver. Quote Link to comment Share on other sites More sharing options...
Krydos Posted December 30, 2016 Share 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 Quote Link to comment Share on other sites More sharing options...
randomguy Posted December 31, 2016 Author Share Posted December 31, 2016 Thanks @Krydos your code is working. Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.