Ruby cgi script

Z

ZippySwish

I put "script.rb" into the cgi-bin folder of my webhost, but nothing's
happening. What am I doing wrong?

script.rb containing for example:

#!/usr/bin/ruby
puts "<html><body><p>Hello World!</p></body></html>"


(the path to ruby is correct according to the helpfiles from my
provider)
 
B

Brian Candler

ZippySwish said:
I put "script.rb" into the cgi-bin folder of my webhost, but nothing's
happening.

I very much doubt "nothing" is happening. But perhaps you don't see
anything in your browser.

A better way to test from the client machine is to use telnet instead of
a web browser. Type the following:

telnet www.yourhost.com 80
GET /cgi-bin/script.rb HTTP/1.0
Host: www.yourhost.com
<blank line>

and see what response comes back. Paste it here if it doesn't make
sense.
script.rb containing for example:

#!/usr/bin/ruby
puts "<html><body><p>Hello World!</p></body></html>"

Often you will need

puts "Content-Type: text/html"
puts
puts "... rest of output ..."

That may or may not be the problem. You'll need to be more specific
about what you see.

You may also need to set the execute bit on script.rb (chmod +x
script.rb - but if you're on a hosted service you may be able to do this
over FTP/SFTP with a 'site chmod' command. Consult your service
provider)
 
Z

ZippySwish

Well, telnet can't get a connection for some reason, but what I mean
by "nothing's happening" is I put

http://www.myhost.com/cgi-bin/script.rb

and get a nothing but white space in return.

The file is set to executable.

I emailed my provider but it may be a while before I get an answer.
 
H

Hassan Schroeder

Well, telnet can't get a connection for some reason,

That's bad -- you should figure that out; direct access via telnet is a
useful troubleshooting tool.
but what I mean
by "nothing's happening" is I put

http://www.myhost.com/cgi-bin/script.rb

and get a nothing but white space in return.

What do your logs say?

And if this is bypassing any server handling, you need to provide the
appropriate HTTP headers, not just the HTML...
 
B

Brian Candler

ZippySwish said:
Well, telnet can't get a connection for some reason

Then investigate. What *exactly* do you see when you try a telnet?

If you post the real hostname here, we can try it for you.
 
Z

ZippySwish

Hey,

turns out my End Of Line characters had the wrong format.

Problem is fixed now.

Thanks everyone!
 
H

Hassan Schroeder

Are you sure the hosting provider actually allows telnet connections?

You probably shouldn't use telnet anyway -- try SSH instead.

Dude, totally missing the point -- the idea is to use your local telnet
client to test the connection to *port 80* and directly examine the
http server's response.

Nothing to do with logins, passwords, etc.
 
M

Michael Monaghan

[Note: parts of this message were removed to make it a legal post.]

Alternatively, the Firefox WebDeveloper plugin allows you to view the http
response.

~m

On Thu, Dec 4, 2008 at 12:54 PM, Hassan Schroeder <
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,780
Messages
2,569,608
Members
45,241
Latest member
Lisa1997

Latest Threads

Top