Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > Ruby > IO.popen and wait for command to finish

Reply
Thread Tools

IO.popen and wait for command to finish

 
 
Uros
Guest
Posts: n/a
 
      04-14-2006
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

 
Reply With Quote
 
 
 
 
Robert Klemme
Guest
Posts: n/a
 
      04-14-2006
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


 
Reply With Quote
 
 
 
 
Uros
Guest
Posts: n/a
 
      04-18-2006
Hello Robert,

thanks for your answer. That did the trick.

br,
uros

 
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
Print digital photos online - 9 cents per print, plus 10% off. All sizes from 4x6 up to 30x60. Same price for Matte finish and glossy finish nathan_usny Digital Photography 2 09-12-2005 11:30 PM
Print digital photos online - 9 cents per print, plus 10% off. All sizes from 4x6 up to 30x60. Same price for Matte finish and glossy finish nathan_usny Digital Photography 0 09-12-2005 06:09 PM
How to wait for multiple threads to finish Gary J Java 19 08-31-2004 08:19 AM
Do I have to wait for my thread to finish? mike Java 6 08-09-2004 09:45 PM
Let browser say "done" immediately after parent finish and do not wait child. Zhidian Du Perl Misc 2 02-21-2004 05:41 PM



Advertisments