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 "<html><body><p>Hello World!</p></body></html>"

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

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

···

2008/12/2 ZippySwish <fischer.jan@gmail.com>:

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

--
Thomas Preymesser
thopre@gmail.com

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
<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)

···

--
Posted via http://www.ruby-forum.com/\.

Thanks everyone so far, I'll try some more

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.

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...

···

On Tue, Dec 2, 2008 at 11:04 AM, ZippySwish <fischer.jan@gmail.com> wrote:

--
Hassan Schroeder ------------------------ hassan.schroeder@gmail.com

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.

···

--
Posted via http://www.ruby-forum.com/\.

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 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.

--
Chad Perrin [ content licensed PDL: http://pdl.apotheon.org ]
Quoth Albert Camus: "An intellectual is someone whose mind watches
itself."

Hey,

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

Problem is fixed now.

Thanks everyone!

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 Thu, Dec 4, 2008 at 9:24 AM, Chad Perrin <perrin@apotheon.com> wrote:

Are you sure the hosting provider actually allows telnet connections?

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

--
Hassan Schroeder ------------------------ hassan.schroeder@gmail.com

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

~m

···

On Thu, Dec 4, 2008 at 12:54 PM, Hassan Schroeder < hassan.schroeder@gmail.com> wrote:

On Thu, Dec 4, 2008 at 9:24 AM, Chad Perrin <perrin@apotheon.com> 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.

--
Hassan Schroeder ------------------------ hassan.schroeder@gmail.com

You're right -- I missed that point, probably because I tend to use other
tools for the same purpose.

···

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

On Thu, Dec 4, 2008 at 9:24 AM, Chad Perrin <perrin@apotheon.com> 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.

--
Chad Perrin [ content licensed PDL: http://pdl.apotheon.org ]
awj @reddit: "The terms never and always are never always true."