Hi there, I have a database with phonenumbers, and I want to make a function that runs a command for each of these numbers, with the number as an argument Something like this in Perl: system("/bin/command $number"); mysql> select * from numbers where list = "one" +----+----------+----------+---------------------+-----------+ | id | number | name | email | list | +----+----------+----------+---------------------+-----------+ | 2 | 9341 | Martin | m@home.com | one +----+----------+----------+---------------------+-----------+ It would be very helpful if anyone could give me some examples on how to achieve this! :) I?ll be very grateful for all help I can get! Best regards, Martin Stabenfeldt
> I have a database with phonenumbers, and I want to make a function > that runs a command for each of these numbers, with the number as an > argument > > Something like this in Perl: > system("/bin/command $number"); > > +----+----------+----------+---------------------+-----------+ > | id | number | name | email | list | > +----+----------+----------+---------------------+-----------+ > | 2 | 9341 | Martin | m@home.com | one > +----+----------+----------+---------------------+-----------+Select the desired records in the controller. Then do a: for person in @people system(/bin/command person.number) end regards Claus
Hello, On Mar 22, 2006, at 5:15 PM, Claus Guttesen wrote:>> I have a database with phonenumbers, and I want to make a function >> that runs a command for each of these numbers, with the number as an >> argument >> >> Something like this in Perl: >> system("/bin/command $number"); >> >> +----+----------+----------+---------------------+-----------+ >> | id | number | name | email | list | >> +----+----------+----------+---------------------+-----------+ >> | 2 | 9341 | Martin | m@home.com | one >> +----+----------+----------+---------------------+-----------+ > > Select the desired records in the controller. Then do a: > > for person in @people > system(/bin/command person.number) > endThanks, Claus! But I didn?t quite get it to work Here?s what I have done. - index.rhtml: <%= link_to ''Iterate over all the numbers'', { :action => ''iterate'', }, %> - numbers_controller: def iterate @people = Number.find(:all, :conditions => "list = ''one''") for person in @people system("echo ''person.number'' > /tmp/outout") end end $ cat /tmp/outout person.number How do I make it echo/print the variable, not just the name? I tried with and without '' around person.number. Best regards, Martin Stabenfeldt
try this system("echo #{person.number} > /tmp/outout") Gokhan www.sylow.net -- Posted via http://www.ruby-forum.com/.
with_irony do wow! i am deeply impressed... end> --- Urspr?ngliche Nachricht --- > Von: Gokhan Arli <gokhan@sylow.net> > An: rails@lists.rubyonrails.org > Betreff: [Rails] Re: foreach item in column > Datum: Thu, 23 Mar 2006 12:28:49 +0100 > > try this > system("echo #{person.number} > /tmp/outout") > > Gokhan > www.sylow.net > > -- > Posted via http://www.ruby-forum.com/. > _______________________________________________ > Rails mailing list > Rails@lists.rubyonrails.org > http://lists.rubyonrails.org/mailman/listinfo/rails >
sorry, I though this is the whole posting! :-(> --- Urspr?ngliche Nachricht --- > Von: "Peter Ertl" <pertl@gmx.org> > An: rails@lists.rubyonrails.org > Betreff: Re: [Rails] Re: foreach item in column > Datum: Thu, 23 Mar 2006 12:31:57 +0100 (MET) > > with_irony do > wow! i am deeply impressed... > end > > > > --- Urspr?ngliche Nachricht --- > > Von: Gokhan Arli <gokhan@sylow.net> > > An: rails@lists.rubyonrails.org > > Betreff: [Rails] Re: foreach item in column > > Datum: Thu, 23 Mar 2006 12:28:49 +0100 > > > > try this > > system("echo #{person.number} > /tmp/outout") > > > > Gokhan > > www.sylow.net > > > > -- > > Posted via http://www.ruby-forum.com/. > > _______________________________________________ > > Rails mailing list > > Rails@lists.rubyonrails.org > > http://lists.rubyonrails.org/mailman/listinfo/rails > > > _______________________________________________ > Rails mailing list > Rails@lists.rubyonrails.org > http://lists.rubyonrails.org/mailman/listinfo/rails >