From: Sky Yin Date: 2006-01-04T07:55:23+09:00 Subject: Re: Help on I/O pipe ------=_Part_30564_22569602.1136328908228 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: quoted-printable Content-Disposition: inline Thank Yohanes for the detailed explanation. I've just tried using io =3D IO.popen("optimizer.exe", "r+") io.puts "..." #stdin wrote: > > On Tue, 3 Jan 2006, Sky Yin wrote: > > > One process of my analysis program uses an external non-linear > optimizer. > > That optimizer needs a model file as the argument. The current approach > I > > employ to accomplish this is to create a model file on disk everytime > > running the optimizer. The code is simply like > > > > @model =3D File.open("model.mod", "w") > > ... > > @model.close > > result =3D `optimizer.exe model.mod` > > > > The problem is that I have to repeat running optimizer on different > models > > many many times during the analysis. I wonder if such heavy writing on = a > > single file will do any harm to my hard disk. My concern of improving i= t > is > > to use I/O pipe to feed the optimizer without the needs to create real > model > > files. Can anyone give me some tips or examples on using the shell pipe= ? > The > > rdoc isn't so clear. > > > > Thanks > > assuming that your analysis code can read it's input sequentially you > might > want to try session: > > require 'session' > > sh =3D Session::new > > model_input =3D ... > > stdout, stderr =3D sh.execute 'optimizer.exe', 'stdin' =3D> model_inpu= t > > p sh.exitstatus > > regards. > > -a > -- > > =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D > | ara [dot] t [dot] howard [at] noaa [dot] gov > | all happiness comes from the desire for others to be happy. all misery > | comes from the desire for oneself to be happy. > | -- bodhicaryavatara > > =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D > > > -- Blog >>> http://spaces.msn.com/members/skyincookoo ------=_Part_30564_22569602.1136328908228--