From: Patrick Fernie Date: 2005-12-27T09:29:56+09:00 Subject: Re: writing to a file converting it needs a thread ? From your snippet it looks like you need to be calling .close (if you're done working with the file) or .flush (if not) on tmpFile before you call an external command on it; otherwise, the File is left open and the contents aren't necessarily in sync with what you've puts'd. When you exit the ruby process, however, the File is automatically flush'd, so it is then in sync, so when you call iconv from your prompt, it works as expected. -P On 12/26/05, Une b�vue wrote: > i have a small script building an xml string and, afterwards, i need to > convert the string. > > basically i do : > xml="" > album_list.each do |k,l| > xml=xml+" organization=\"#{l[3]}\"/>\n" > end > tmpFile.puts xml > > system("iconv -c -s -f MACROMAN -t UTF-8 #{tmpName} > > #{xmlDir}/#{xmlName}") > > > and the resulting conversion lacks of one half a line to 26 lines, > depending the number of lines (some how randomly)) > > > if after having done that, i launch iconv from command line by : > iconv -c -s -f MACROMAN -t UTF-8 /tmp/AddressBook-MACROMAN.xml > > AddressBook.xml > > ("same" command as system("...")) > > i get all the 156 lines ??? > > does than means system("iconv -c ...") is started within the ruby script > before the end of "tmpFile.puts xml" in which case i'd have to sync > writing by puts and reading by iconv ? > > if this is true, how to do that ? > -- > une b�vue > >