Ruby cgi script

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 “

Hello World!

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

2008/12/2 ZippySwish [email protected]:

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

http://www.linuxjournal.com/article/8356

ZippySwish wrote:

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

and see what response comes back. Paste it here if it doesn’t make
sense.

script.rb containing for example:

#!/usr/bin/ruby
puts “

Hello World!

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)

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.

On Tue, Dec 2, 2008 at 11:04 AM, ZippySwish [email protected]
wrote:

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…

ZippySwish wrote:

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.

Thanks everyone so far, I’ll try some more

Hey,

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

Problem is fixed now.

Thanks everyone!

On Thu, Dec 4, 2008 at 9:24 AM, Chad P. [email protected] wrote:

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.

On Wed, Dec 03, 2008 at 04:04:28AM +0900, ZippySwish wrote:

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.

Are you sure the hosting provider actually allows telnet connections?

You probably shouldn’t use telnet anyway – try SSH instead. My first
rule when looking at shared hosting providers is that I won’t use one
that doesn’t allow me encrypted remote access. Since telnet isn’t
encrypted, a man-in-the-middle attack (among other means) can be used to
intercept your username and password when you try to log in via telnet.

On Fri, Dec 05, 2008 at 02:54:55AM +0900, Hassan S. wrote:

Nothing to do with logins, passwords, etc.
You’re right – I missed that point, probably because I tend to use
other
tools for the same purpose.

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

~m

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