From: Bob Hutchison Date: 2006-08-05T23:28:44+09:00 Subject: Re: How to tell when IO::popen is finished? On Aug 3, 2006, at 7:19 PM, Daniel N wrote: > I'm on windows :) I don't need root. Ohhh gives me goosebumps ;) > > The problem isn't that the file isn't created. It's just that I > don't know > when it's finished being written. > > I want to incorporate this into an app but I don't want to go > trying to grab > the image if it doenst exist yet. It is possible that the OS is simply not yet finished writing the file to disk. In unix this is forced by calling fsync (or sync on the command line). I've got no idea what you do in windows. The first thing to try is to find out what the windows equivalent of the command line 'sync' and run it before trying to open the png. If that works then you can get fancy... Assuming the CL sync worked... In ruby the IO class has two methods defined: fsync which is defined on an instance of the class, and sync which is defined on the class. IO.sync won't do what you need, it just forces ruby to write its buffers. You can try opening the png file and calling fsync from there, don't know if that will work. Alternatively, check to see of gnuplot will either give you the IO object somehow or can be asked to fsync. If not, you might be able to sneak into Gnuplot aliasing a method or re-opening the class or some other trick and insert the fsync. Cheers, Bob ---- Bob Hutchison -- blogs at Recursive Design Inc. -- Raconteur -- xampl for Ruby --