From: Martin Boese Date: 2010-03-25T07:30:04+09:00 Subject: Re: call a ruby script from html 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 = "

Running Program

" end end server = WEBrick::HTTPServer.new(:Port => 4000) server.mount("/run", RunScript) trap("INT"){ server.shutdown } server.start