IO.popen and wait for command to finish

U

Uros

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
 
R

Robert Klemme

Uros said:
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
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,769
Messages
2,569,580
Members
45,055
Latest member
SlimSparkKetoACVReview

Latest Threads

Top