Hello- I have an application where I would like to issue Ruby commands from a Rails application and pipe the resulting stuff from the command line into a Rails variable. Does anyone have a good way to do this? Example: Call to Ruby Program:>ruby callFunction.rb some_params ( where ''some_params'' is given from a form in the Rails app)Results Returned:>result - answer1 >result - answer2 >....Ideally then I could have these results stored in a variable to put in my view. Thanks, let me know if this is not clear! --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
def ruby_command @result = `cd /Users/rails/Desktop/;ls` end view <%= @result %> A start. -- Posted via http://www.ruby-forum.com/. --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
At what point does the command get issued? When the view is rendered? I''m assuming this would work for Windows environment too? Thanks! On Dec 15, 9:34 am, Peter De jong <rails-mailing-l...-ARtvInVfO7ksV2N9l4h3zg@public.gmane.org> wrote:> def ruby_command > @result = `cd /Users/rails/Desktop/;ls` > end > > view > <%= @result %> > > A start. > -- > Posted viahttp://www.ruby-forum.com/.--~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
I tried this out an when the view is rendered, all I get is what @result was. So in the example below, my view displays this: Result: `cd /Users/rails/Desktop/;ls` On Dec 15, 9:47 am, pete <peterbattag...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> At what point does the command get issued? When the view is rendered? > > I''m assuming this would work for Windows environment too? > > Thanks! > > On Dec 15, 9:34 am, Peter De jong <rails-mailing-l...-ARtvInVfO7ksV2N9l4h3zg@public.gmane.org> > wrote: > > > def ruby_command > > @result = `cd /Users/rails/Desktop/;ls` > > end > > > view > > <%= @result %> > > > A start. > > -- > > Posted viahttp://www.ruby-forum.com/.--~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
Pete, check that you''re using backticks (and not single-quotes) in your code above. - BD On Dec 15, 11:36 am, pete <peterbattag...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> I tried this out an when the view is rendered, all I get is what > @result was. > > So in the example below, my view displays this: > > Result: `cd /Users/rails/Desktop/;ls` > > On Dec 15, 9:47 am, pete <peterbattag...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote: > > > At what point does the command get issued? When the view is rendered? > > > I''m assuming this would work for Windows environment too? > > > Thanks! > > > On Dec 15, 9:34 am, Peter De jong <rails-mailing-l...-ARtvInVfO7ksV2N9l4h3zg@public.gmane.org> > > wrote: > > > > def ruby_command > > > @result = `cd /Users/rails/Desktop/;ls` > > > end > > > > view > > > <%= @result %> > > > > A start. > > > -- > > > Posted viahttp://www.ruby-forum.com/.--~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
Um. I think all the dude wanted to do was to use Ruby code in Rails. Something like: <% @result = 1 + 2 %> <%= @result %> Am I wrong? If you want to run your little ruby file there from your Rails app, stick it in lib and it will automatically be included if it is a class. If it is a module you will have to do include ModuleName to include it. On Dec 17, 2007 6:54 AM, Brian Dainton <brian.dainton-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> > Pete, check that you''re using backticks (and not single-quotes) in > your code above. > > - BD > > On Dec 15, 11:36 am, pete <peterbattag...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote: > > I tried this out an when the view is rendered, all I get is what > > @result was. > > > > So in the example below, my view displays this: > > > > Result: `cd /Users/rails/Desktop/;ls` > > > > On Dec 15, 9:47 am, pete <peterbattag...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote: > > > > > At what point does the command get issued? When the view is rendered? > > > > > I''m assuming this would work for Windows environment too? > > > > > Thanks! > > > > > On Dec 15, 9:34 am, Peter De jong <rails-mailing-l...-ARtvInVfO7ksV2N9l4h3zg@public.gmane.org> > > > wrote: > > > > > > def ruby_command > > > > @result = `cd /Users/rails/Desktop/;ls` > > > > end > > > > > > view > > > > <%= @result %> > > > > > > A start. > > > > -- > > > > Posted viahttp://www.ruby-forum.com/. > > >-- Ryan Bigg http://www.frozenplague.net --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---