D
David Street
[Note: parts of this message were removed to make it a legal post.]
A third party has written a program that passes a parameter via the GET
method. I need to use it to call a Ruby script and pass a parameter.
I have researched and experimented for days and cannot figure out how to
retrieve a GET parameter in a Ruby script.
Test code to pass the parameter is:
---------------------------------------------
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<title>Test Get</title>
</head>
<body>
<form action = 'http://localhost/cgi-bin/test.rb' method = 'get' />
<input type = 'hidden' name = 'parameter' value = '12345' />
<input type = "submit" value = "SUBMIT" />
</form>
</body>
</html>
---------------------------------------------
I believe I should retrieve it with something like this:
test.rb
--------------------------------------------------------------------
#!/usr/bin/ruby
require 'net/http'
require 'uri'
begin
print "Content-type: text/html\r\n\r\n"
server = URI.parse( 'localhost/cgi-bin/test.rb' )
http = Net::HTTP.start( server.host, server.port )
response = http.get( server.path )
print response.body
# or maybe
response = http.get['parameter']
print response
end
-------------------------------------------------------------------
But I always receive 'nil'. (I've tried many variations).
http.head( 'www.website.com' ) works and returns values as expected.
I'm sure this must be simple, but I have tried everything I can think of
and can't find an example anywhere.
Thanks to anyone who can assist.
-David
A third party has written a program that passes a parameter via the GET
method. I need to use it to call a Ruby script and pass a parameter.
I have researched and experimented for days and cannot figure out how to
retrieve a GET parameter in a Ruby script.
Test code to pass the parameter is:
---------------------------------------------
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<title>Test Get</title>
</head>
<body>
<form action = 'http://localhost/cgi-bin/test.rb' method = 'get' />
<input type = 'hidden' name = 'parameter' value = '12345' />
<input type = "submit" value = "SUBMIT" />
</form>
</body>
</html>
---------------------------------------------
I believe I should retrieve it with something like this:
test.rb
--------------------------------------------------------------------
#!/usr/bin/ruby
require 'net/http'
require 'uri'
begin
print "Content-type: text/html\r\n\r\n"
server = URI.parse( 'localhost/cgi-bin/test.rb' )
http = Net::HTTP.start( server.host, server.port )
response = http.get( server.path )
print response.body
# or maybe
response = http.get['parameter']
print response
end
-------------------------------------------------------------------
But I always receive 'nil'. (I've tried many variations).
http.head( 'www.website.com' ) works and returns values as expected.
I'm sure this must be simple, but I have tried everything I can think of
and can't find an example anywhere.
Thanks to anyone who can assist.
-David