[lnkForumImage]
TotalShareware - Download Free Software

Confronta i prezzi di migliaia di prodotti.
Asp Forum
 Home | Login | Register | Search 


 

Forums >

comp.lang.ruby

IO.popen and wait for command to finish

Uros

4/14/2006 7:31:00 AM

Hello,

I have this for loop thats executing

IO.popen ("mysql database+i < database.sql")

It seems that the databases don't get populated with all the data,
since it seems that one mysql loop doesn't finish as the other one
start. So it seems, bear in mind I'm no expert, just trying to
trubleshoot the problem.

When I do a manual mysq < database.sql it works.

Is there I way to make ruby wait for the command to finish, befor
continuing to loop?

br,
uros

2 Answers

Robert Klemme

4/14/2006 12:54:00 PM

0

Uros wrote:
> Hello,
>
> I have this for loop thats executing
>
> IO.popen ("mysql database+i < database.sql")
>
> It seems that the databases don't get populated with all the data,
> since it seems that one mysql loop doesn't finish as the other one
> start. So it seems, bear in mind I'm no expert, just trying to
> trubleshoot the problem.
>
> When I do a manual mysq < database.sql it works.
>
> Is there I way to make ruby wait for the command to finish, befor
> continuing to loop?

I'd just read the IO until the end. You should do that anyway because
otherwise the process my block

IO.popen ("mysql database+i < database.sql") do |io|
io.each_line {}
end

Kind regards

robert


Uros

4/18/2006 5:22:00 AM

0

Hello Robert,

thanks for your answer. That did the trick. :)

br,
uros