Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > Ruby > call a ruby script from html

Reply
Thread Tools

call a ruby script from html

 
 
Mario Ruiz
Guest
Posts: n/a
 
      03-24-2010
I would like to call a ruby script from a html page passing a few
parameters, something like:
<a href="c:/myS/search.rb param1 param2">Search</a>

Anybody knows how to do it?

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

 
Reply With Quote
 
 
 
 
Richard Conroy
Guest
Posts: n/a
 
      03-24-2010
[Note: parts of this message were removed to make it a legal post.]

Not too sure what you are trying to do here. The fact that you are invoking
against your local system is a bit weird, and I dont think that is workable.
Might work for locally loaded Javascript, but not in a HREF.

If you are hitting a server, this can be made to work, as CGI (similar to
how
you would invoke against a PHP script), but CGI is not a popular way to
run Ruby web apps, and it is very poorly documented in general (its eclipsed
by all the other methods).

Again, your parameters would have to be appropriate for a query string, you
couldn't
rely on passing them in as command line arguments.

For isntance:

<a href="/scripts/ruby.rb?param1=value1&param2=value2">Search<a>

On Wed, Mar 24, 2010 at 4:28 PM, Mario Ruiz <> wrote:

> I would like to call a ruby script from a html page passing a few
> parameters, something like:
> <a href="c:/myS/search.rb param1 param2">Search</a>
>
> Anybody knows how to do it?
>
> Thanks.
> --
> Posted via http://www.ruby-forum.com/.
>
>



--
http://richardconroy.blogspot.com

 
Reply With Quote
 
 
 
 
Mario Ruiz
Guest
Posts: n/a
 
      03-24-2010
What I'm trying to do is to call a ruby script that admits parameters.
This program is going to be run locally.
The problem is no parameters are taken since the explorers try to
download the file instead of running the file.

Another way to solve this would be to run directly the code on the
page... is that possible?

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

 
Reply With Quote
 
Mario Antonetti
Guest
Posts: n/a
 
      03-24-2010
[Note: parts of this message were removed to make it a legal post.]

On Wed, Mar 24, 2010 at 10:56 AM, Richard Conroy
<>wrote:

> Not too sure what you are trying to do here. The fact that you are invoking
> against your local system is a bit weird, and I dont think that is
> workable.
> Might work for locally loaded Javascript, but not in a HREF.
>
> If you are hitting a server, this can be made to work, as CGI (similar to
> how
> you would invoke against a PHP script), but CGI is not a popular way to
> run Ruby web apps, and it is very poorly documented in general (its
> eclipsed
> by all the other methods).
>
> Again, your parameters would have to be appropriate for a query string, you
> couldn't
> rely on passing them in as command line arguments.
>
> For isntance:
>
> <a href="/scripts/ruby.rb?param1=value1&param2=value2">Search<a>
>
> On Wed, Mar 24, 2010 at 4:28 PM, Mario Ruiz <> wrote:
>
> > I would like to call a ruby script from a html page passing a few
> > parameters, something like:
> > <a href="c:/myS/search.rb param1 param2">Search</a>
> >
> > Anybody knows how to do it?
> >
> > Thanks.
> > --
> > Posted via http://www.ruby-forum.com/.
> >
> >

>
>
> --
> http://richardconroy.blogspot.com




If the ruby script doesn't rely on being run on the server, you could try
HotRuby: http://hotruby.yukoba.jp/

 
Reply With Quote
 
Richard Conroy
Guest
Posts: n/a
 
      03-24-2010
[Note: parts of this message were removed to make it a legal post.]

On Wed, Mar 24, 2010 at 5:05 PM, Mario Ruiz <> wrote:

> What I'm trying to do is to call a ruby script that admits parameters.
> This program is going to be run locally.
> The problem is no parameters are taken since the explorers try to
> download the file instead of running the file.
>
> Another way to solve this would be to run directly the code on the
> page... is that possible?
>
>

There are a couple of exotic ways to run ruby in your browser. All of them
work like
Java applets.

You can Jar up your ruby code with JRuby, and you might be able to locally
invoke on
it that way.

A similar method works for IronRuby, to get your Ruby code inside a
silverlight applet.

--
http://richardconroy.blogspot.com

 
Reply With Quote
 
Mario Ruiz
Guest
Posts: n/a
 
      03-24-2010
but in HotRuby only a few implemented methods are allowed.
--
Posted via http://www.ruby-forum.com/.

 
Reply With Quote
 
Martin Boese
Guest
Posts: n/a
 
      03-24-2010
On Thu, 25 Mar 2010 02:05:10 +0900
Mario Ruiz <> wrote:

> What I'm trying to do is to call a ruby script that admits
> parameters. This program is going to be run locally.
> The problem is no parameters are taken since the explorers try to
> download the file instead of running the file.
>
> Another way to solve this would be to run directly the code on the
> page... is that possible?
>
> Thanks


I don't know of any browser what would execute the file, even if
the page was loaded locally....

But running a small local webserver will work. Ruby the code below and
then link to http://localhost:4000/run .

require 'webrick'

class RunScript < WEBrick::HTTPServlet::AbstractServlet
def do_GET(req, res)
system("c:/myS/search.rb param1 param2")
res.status = 200
res['Content-Type'] = 'text/html'
res.body = "<h1>Running Program</h1>"
end
end


server = WEBrick::HTTPServer.new(ort => 4000)
server.mount("/run", RunScript)

trap("INT"){ server.shutdown }
server.start


 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
(How) Can you run another ruby script, from a ruby script? 3lionz Wexler Ruby 2 08-24-2010 04:27 AM
how to test a ruby script from another ruby script? Saravanan Sundaramoorthy Ruby 1 07-19-2010 12:06 PM
Pass variables to arbitrary ruby script: ruby script.rb Mario Gr Ruby 3 07-04-2009 06:00 AM
"ruby script.rb" versus "xterm -e ruby script.rb" Sy Ruby 0 04-16-2005 12:08 AM
How to make Perl Script "POST" call from another Perl Script??? Wet Basement Perl 1 07-15-2003 10:25 PM



Advertisments
 



1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57