Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > Ruby > ruby on server side

Reply
Thread Tools

ruby on server side

 
 
Rajesh Huria
Guest
Posts: n/a
 
      11-29-2010
Hi,
I am new to this forum. so forgive me if my post replicating old post.
Ok I have a ruby script with xml input file. ruby script extract
required info from xml file and present in html output with help of
nokogiri lib.
Ruby script is working fine. right now, we need to install ruby and
nokogiri on all machines to run ruby script. I want to put it like a
website. so i configured apache over my ubuntu machine. its working
fine. i can access index page on server from all machines.

What i want?

I want to design html page with form tag like:
<form action="server address"
enctype="multipart/form-data" method="post">
<p>
Please specify a file<br>
<input type="file" name="datafile" size="40">
</p>
<div>
<input type="submit" value="Send">
</div>
</form

So whenever user select xml file and press send. input file should go to
ruby script on server and html output will be generated. user get output
over his/her browser. I dont know how to do it i am trying to figure
it out.

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

 
Reply With Quote
 
 
 
 
Steve Klabnik
Guest
Posts: n/a
 
      11-29-2010
[Note: parts of this message were removed to make it a legal post.]

You'll want to check out one of the many Ruby web frameworks. If all you
want is something simple like this, I'd suggest using Sinatra:
http://sinatrarb.com/

Since you're using Apache, I'd suggest phusion passenger to get it talking
with Sinatra: http://www.modrails.com/

 
Reply With Quote
 
 
 
 
Rajesh Huria
Guest
Posts: n/a
 
      12-01-2010
Steve Klabnik wrote in post #964767:
> You'll want to check out one of the many Ruby web frameworks. If all you
> want is something simple like this, I'd suggest using Sinatra:
> http://sinatrarb.com/
>
> Since you're using Apache, I'd suggest phusion passenger to get it
> talking
> with Sinatra: http://www.modrails.com/


this looks quite complicated to me
is there any way, i can just invoke ruby script on server side?
Also, how i can feed input tag of form as input to my ruby script?

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

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

On Wed, Dec 1, 2010 at 9:34 AM, Rajesh Huria <> wrote:

> Steve Klabnik wrote in post #964767:
> > You'll want to check out one of the many Ruby web frameworks. If all you
> > want is something simple like this, I'd suggest using Sinatra:
> > http://sinatrarb.com/
> >
> > Since you're using Apache, I'd suggest phusion passenger to get it
> > talking
> > with Sinatra: http://www.modrails.com/

>
> this looks quite complicated to me
> is there any way, i can just invoke ruby script on server side?
>


You mean using CGI? Its possible. You will need to configure your web server
for it. Its slow though.



> Also, how i can feed input tag of form as input to my ruby script?
>


Check out the ruby CGI library. I would guess that is a good starting point
for what you want to achieve.
http://ruby-doc.org/core/classes/CGI.html

For something simple, you really cant beat Sinatra. It is not typical to
make Ruby web programs just using CGI, or have PHP-like deployment.

--
http://richardconroy.blogspot.com | http://twitter.com/RichardConroy

 
Reply With Quote
 
Bob Hutchison
Guest
Posts: n/a
 
      12-01-2010

On 2010-12-01, at 4:34 AM, Rajesh Huria wrote:

> Steve Klabnik wrote in post #964767:
>> You'll want to check out one of the many Ruby web frameworks. If all you
>> want is something simple like this, I'd suggest using Sinatra:
>> http://sinatrarb.com/
>>
>> Since you're using Apache, I'd suggest phusion passenger to get it
>> talking
>> with Sinatra: http://www.modrails.com/

>
> this looks quite complicated to me


If you can configure Apache, you're going to find this easy

Have a look at the sinatra book:

http://sinatra-book.gittr.com/

or this video:

http://rubyconf2008.confreaks.com/li...-services.html

> is there any way, i can just invoke ruby script on server side?
> Also, how i can feed input tag of form as input to my ruby script?


All that is covered in both of those links.

Cheers,
Bob

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


----
Bob Hutchison
Recursive Design Inc.
http://www.recursive.ca/
weblog: http://xampl.com/so





 
Reply With Quote
 
Rajesh Huria
Guest
Posts: n/a
 
      12-06-2010
Ok guys, thnx for the answers.. i am freaked out with all experiments
here is the code snipshots:
index.php:
<html><body>
<form action="upload.php" enctype="multipart/form-data" method="post">
<p>
Please specify a file to Parse:<br>
<input type="file" name="file" id="file">
</p>
<div>
<input type="submit" value="Parse">
</div>
</form>
</body>
</html>

upload.php:
<?php
if (//some check)
{
//some code
}
else
{
//some code
system('ruby -v'); // This is giving proper output i.e ruby version
system('ruby myprogram.rb'); // no action
}
?>

myprogram.rb is executing fine over shell but when i try to execute via
upload.php, nothing is happening. Any idea why ruby not working on
server side when accessing via upload.php ?

do i need to do anything on apache side?

i dont have any ruby handler installed on apache? is this could be the
reason?

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

 
Reply With Quote
 
Eugeni Akmuradov
Guest
Posts: n/a
 
      12-06-2010
do user will have a possibilty to pass any parameters to system() call ?

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

 
Reply With Quote
 
Rajesh Huria
Guest
Posts: n/a
 
      12-06-2010
Chad Perrin wrote in post #966635:
> On Tue, Dec 07, 2010 at 03:10:37AM +0900, Rajesh Huria wrote:
>>
>> system('ruby -v'); // This is giving proper output i.e ruby version
>> system('ruby myprogram.rb'); // no action
>>
>> myprogram.rb is executing fine over shell but when i try to execute via
>> upload.php, nothing is happening. Any idea why ruby not working on
>> server side when accessing via upload.php ?

>
> I suspect you are having some path issues. The PHP script probably
> isn't
> "aware" of how to find the myprogram.rb script. Try using the full path
> to the Ruby script there.


I checked with getcwd(); // current working directory on server

In this case, myprogram.rb lies in same directory as current working
directory. do you think, its still path problem?


> Then . . . assuming that works, you might want to look into how you can
> make path handling a little more robust and flexible. First step, of
> course, is just making sure that the Ruby program will work in this
> context, and you should be able to do it with something like:
>
> system('ruby /absolute/path/to/myprogram.rb');
>
>
>>
>> do i need to do anything on apache side?

>
> It's probably related to the execution context of your PHP script (what
> it "thinks" is its current working directory) and the location of your
> Ruby program.

current working directory and location of ruby program is same

>> i dont have any ruby handler installed on apache? is this could be the
>> reason?

>
> That should not affect the execution of a Ruby script via PHP's system()
> function, as far as I'm aware.


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

 
Reply With Quote
 
Rajesh Huria
Guest
Posts: n/a
 
      12-06-2010
Eugeni Akmuradov wrote in post #966675:
> do user will have a possibilty to pass any parameters to system() call ?


system takes all linux commands with options. i am not sure about
parameters

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

 
Reply With Quote
 
John W Higgins
Guest
Posts: n/a
 
      12-06-2010
[Note: parts of this message were removed to make it a legal post.]

Good Afternoon,

Can I ask the stupid question? Why not recode the ruby script in PHP if you
are unwilling to do this the right way and use something along the lines of
Sinatra et al.?

John

 
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
Server-Side Control - Embedded Server-Side Code - Inline Mythran ASP .Net 2 01-22-2005 01:02 AM
client-side browser timeout OR server-side web server timeout?? (please help) jrefactors@hotmail.com HTML 1 01-04-2005 06:13 AM
client-side browser timeout OR server-side web server timeout?? (please help) jrefactors@hotmail.com Javascript 0 01-04-2005 04:06 AM
client-side browser timeout OR server-side web server timeout?? (please help) jrefactors@hotmail.com Java 0 01-04-2005 04:06 AM
data synchronisation - java server side or www server side? Thor Java 1 07-02-2003 05:44 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