[lnkForumImage]
TotalShareware - Download Free Software

Confronta i prezzi di migliaia di prodotti.
Asp Forum
 Home | Login | Register | Search 


 

Forums >

comp.lang.ruby

CGI newbie

Sam

3/5/2009 4:27:00 PM

Hello,

I am starting a personal project to build a configuration webpage for a
small router device. Half of it is already done in perl cgi by someone
else. I want to rewrite that and add to it using ruby and cgi. Does
anyone have some good resources for rubg cgi programming? I am sorta
new to ruby and very new to cgi. Or possibly should I just stick with
the perl cgi that is already partially implemented?

Thank you
Sam

15 Answers

Rolando Abarca

3/5/2009 7:01:00 PM

0

This might help you:

http://lmgtfy.com/?q=ruby+cgi+tutori...

;-)

On Mar 5, 2009, at 1:27 PM, Sam wrote:

> Hello,
>
> I am starting a personal project to build a configuration webpage
> for a small router device. Half of it is already done in perl cgi
> by someone else. I want to rewrite that and add to it using ruby
> and cgi. Does anyone have some good resources for rubg cgi
> programming? I am sorta new to ruby and very new to cgi. Or
> possibly should I just stick with the perl cgi that is already
> partially implemented?
>
> Thank you
> Sam


Best regards,
--
Rolando Abarca M.





Phlip

3/5/2009 7:26:00 PM

0

Sam wrote:
> Hello,
>
> I am starting a personal project to build a configuration webpage for a
> small router device. Half of it is already done in perl cgi by someone
> else. I want to rewrite that and add to it using ruby and cgi. Does
> anyone have some good resources for rubg cgi programming? I am sorta
> new to ruby and very new to cgi. Or possibly should I just stick with
> the perl cgi that is already partially implemented?

Speaking from copious personal experience with raw CGI in both Perl and Ruby...

....Rewrite the app using Ruby on Rails. You will spend very little time
twiddling with the raw HTTP messages, and you will find re-implementing the
actual logic very easy.

If you try to replicate this program in Ruby, it would not be much of an
improvement over Perl.

--
Phlip

Phlip

3/5/2009 7:33:00 PM

0

> http://lmgtfy.com/?q=ruby+cgi+tutori...
>
> ;-)

For future reference, posting that thing is the equivalent of saying "I am too
stupid to be able to exceed Google's average answer for this newsgroup's topic."

So anyone who doesn't mind declaring themselves to be idiots, by all means keep
posting it!

--
Phlip

Jeff Schwab

3/5/2009 7:48:00 PM

0

Phlip wrote:
>> http://lmgtfy.com/?q=ruby+cgi+tutori...
>>
>> ;-)
>
> For future reference, posting that thing is the equivalent of saying "I
> am too stupid to be able to exceed Google's average answer for this
> newsgroup's topic."
>
> So anyone who doesn't mind declaring themselves to be idiots, by all
> means keep posting it!

I google a Rails error message the other day, and the first thing that
came up was a mailing-list response with nothing but an lmgtfy link.
You know, it was funny once or twice, but now it's just Rick-rolling.

Tim Greer

3/5/2009 7:48:00 PM

0

Sam wrote:

> Hello,
>
> I am starting a personal project to build a configuration webpage for
> a
> small router device. Half of it is already done in perl cgi by
> someone
> else. I want to rewrite that and add to it using ruby and cgi. Does
> anyone have some good resources for rubg cgi programming? I am sorta
> new to ruby and very new to cgi. Or possibly should I just stick with
> the perl cgi that is already partially implemented?
>
> Thank you
> Sam

Considering you don't know Ruby or understand CGI (which is something
you can probably learn in minutes or hours), you might not want to try
and re-do it just for the sake of it, if you don't know the language or
interface you'll be using well. If it works now, there's no reason to
change it, though I understand if you want to use it as a project to
help you learn.
--
Tim Greer, CEO/Founder/CTO, BurlyHost.com, Inc.
Shared Hosting, Reseller Hosting, Dedicated & Semi-Dedicated servers
and Custom Hosting. 24/7 support, 30 day guarantee, secure servers.
Industry's most experienced staff! -- Web Hosting With Muscle!

Brian Candler

3/5/2009 9:57:00 PM

0

Sam wrote:
> I want to rewrite that and add to it using ruby and cgi. Does
> anyone have some good resources for rubg cgi programming?

http://www.ruby-doc.org/docs/Progra...

Then click on "Ruby and the Web"

However as others have said, a monolithic CGI which combines both the
application logic and the HTML is likely to suck. Look at Rails or
Sinatra - the first if you like big apps which do everything for you,
but you have to hunt through the docs to find what the feature you're
looking for you, and the latter for something small and easy to
understand, but you have to add in bits of functionality as you need
them.

--
Posted via http://www.ruby-....

David Masover

3/5/2009 11:43:00 PM

0

Phlip wrote:
>> http://lmgtfy.com/?q=ruby+cgi+tutori...
>>
>> ;-)
>
> For future reference, posting that thing is the equivalent of saying
> "I am too stupid to be able to exceed Google's average answer for this
> newsgroup's topic."

Or it's the equivalent of saying "Your question is so simple it could be
answered with a Google search, yet you didn't give us the courtesy of
going that far, and instead chose to bother hundreds of people with YOUR
problem."

And let's face it, that link is a lot tamer than, say:

http://justfuckinggoo...

If you want an answer that exceeds Google's first few search results,
ask a more intelligent question in the first place, and ask it _after_
making a decent effort to find the answer yourself. In fact, here's a
detailed guide on how to ask:

http://catb.org/~esr/faqs/smart-ques...

Common points that a few newbies every _day_ seem to miss:

- Try to find the answer yourself
There's Google, there's archives, there's manuals, there's FAQs.
Those exist for a reason -- to save your time and ours. Even if you
can't find it, showing that you at least made an effort will get you a
bit more respect than "Help, I'm a newbie!"

- Choose your forum carefully
Ruby is not Rails. Ask on the Rails group for Rails questions.

- Follow common etiquette for that forum
Most of the people who care hate top-posting. If you can't be
bothered to spend a few seconds pressing the fscking arrow keys, why
should I bother to spend a few seconds reading your post?

- Don't post homework questions
There seems to be a _lot_ of these on this forum, and they get
answered, unfortunately...
Look, I'm not against helping, but if you're clearly asking me to do
your job for you, I feel like I should be asking to get paid. And if
this actually is your homework (or your job), from some of the questions
asked, I hope you get fired (or fail), and go back to school (or take
the class over) -- not because I hate you, but because your employer
(current or future) deserves better than a Paula Bean:

http://thedailywtf.com/articles/the_brillant_paula...

This particular question is one of a pattern: "I'm a newbie at foo."
Clearly you are, what was the question? "How do I learn foo?" Sigh...

For future reference, keep in mind that you are asking a favor from
quite possibly hundreds of people you've never met. Meet us halfway.
It's probably faster to STFW anyway than it is to ask us -- so it's not
just inconsiderate laziness, it's foolish, self-defeating, inconsiderate
laziness.

And here's a hint: If you at least say "I looked, but I couldn't seem to
find a good tutorial. This page <link> looks outdated..." That at least
shows you tried, and is likely to get a friendlier response.

By the way, I have no problem being called out if I start asking stupid
questions, too. But frankly, I think a harsh answer like lmgtfy, or even
justfuckinggoogleit or STFW, is better than no answer at all. Better for
the user, because they might get their question answered, and they might
even pick up some Google skills. Better for us, because the same person
won't be back tomorrow asking the exact same question, wondering why it
never gets answered.

Sam

3/6/2009 12:40:00 AM

0

Brian Candler wrote:
> Sam wrote:
>> I want to rewrite that and add to it using ruby and cgi. Does
>> anyone have some good resources for rubg cgi programming?
>
> http://www.ruby-doc.org/docs/Progra...
>
> Then click on "Ruby and the Web"
>
> However as others have said, a monolithic CGI which combines both the
> application logic and the HTML is likely to suck. Look at Rails or
> Sinatra - the first if you like big apps which do everything for you,
> but you have to hunt through the docs to find what the feature you're
> looking for you, and the latter for something small and easy to
> understand, but you have to add in bits of functionality as you need
> them.
>


Yes that is about the best example that I have found. Unfortunately
searching google for "ruby cgi" yields many websites all with that same
example (hence why I posted on here). Maybe I should have clarified
this "app" better before. I need to make a couple of webpages for a
small embedded router/bridge that will configure squid proxy and
dansguardian. So pretty simple stuff like writing to text files and
restarting services. I only have 300mhz and 128mb of ram to work with
so I don't know if RoR would be the best idea? After spending most of
today reading, I think my main weak spot is just html form/input
processing since I have never done that before. I guess I might have to
make a trip to the book store...


Sam

David Masover

3/6/2009 8:12:00 PM

0

Sam wrote:
> Maybe I should have clarified this "app" better before.

Probably.

> So pretty simple stuff like writing to text files and restarting
> services. I only have 300mhz and 128mb of ram to work with so I don't
> know if RoR would be the best idea?

I would guess Rails would still work, but a better choice might be
Sinatra, or even Merb if you want a full stack. I am also guessing that
traditional CGI is still not the best choice.

I'm going to say Sinatra and Ruby 1.9.1 are probably what you want.

Brian Candler

3/6/2009 9:25:00 PM

0

David Masover wrote:
>> So pretty simple stuff like writing to text files and restarting
>> services. I only have 300mhz and 128mb of ram to work with so I don't
>> know if RoR would be the best idea?
>
> I would guess Rails would still work, but a better choice might be
> Sinatra, or even Merb if you want a full stack. I am also guessing that
> traditional CGI is still not the best choice.
>
> I'm going to say Sinatra and Ruby 1.9.1 are probably what you want.

I second that. The HTML form processing is already included. Try this
for starters:

require 'rubygems'
require 'sinatra'

get '/' do
haml :index
end

post '/update' do
STDERR.puts params.inspect # <= it's all in the params hash
# do some work
redirect '/'
end

__END__
@@ index
%h1 Hello
%p
OK, so it's a bit unfair of me to tell
a newbie to dive straight in with HAML.
But now I find this easier than form helpers.
%form{:action=>"/update",:method=>"post"}
%label
Type something here:
%input{:type=>"text",:name=>"foo"}
%label
Select one of these:
%select{:name=>"bar"}
%option One
%option Two
%option Three
%input{:type=>"submit",:value=>"go"}
--
Posted via http://www.ruby-....