From: ara.t.howard@... Date: 2006-01-03T23:31:53+09:00 Subject: Re: Help on I/O pipe 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 = File.open("model.mod", "w") > ... > @model.close > result = `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 it 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 = Session::new model_input = ... stdout, stderr = sh.execute 'optimizer.exe', 'stdin' => model_input p sh.exitstatus regards. -a -- =============================================================================== | 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 ===============================================================================