Foreach item in column

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 | [email protected] | one
±—±---------±---------±--------------------±----------+

It would be very helpful if anyone could give me some examples on how
to achieve this! :slight_smile:

I´ll be very grateful for all help I can get!

Best regards,
Martin S._______________________________________________
Rails mailing list
[email protected]
http://lists.rubyonrails.org/mailman/listinfo/rails

| 2 | 9341 | Martin | [email protected] | 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 G. wrote:

| 2 | 9341 | Martin | [email protected] | one
±—±---------±---------±--------------------±----------+

Select the desired records in the controller. Then do a:

for person in @people
system(/bin/command person.number)
end

Thanks, 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 S._______________________________________________
Rails mailing list
[email protected]
http://lists.rubyonrails.org/mailman/listinfo/rails

try this
system(“echo #{person.number} > /tmp/outout”)

Gokhan
www.sylow.net

sorry, I though this is the whole posting!

:frowning:

with_irony do
wow! i am deeply impressed…
end