From: ara.t.howard@... Date: 2006-09-20T14:02:21+09:00 Subject: Re: piping input when shelling out On Wed, 20 Sep 2006, Caio Chassot wrote: > > On 2006-09-19, at 23:17 , ara.t.howard@noaa.gov wrote: > >> you're making it pretty hard on yourself: > > I guess I was :) > >> my session and open4 lib both abstract this largely, including a good deal >> of >> error handling. there is also the built-in open3 module. check out the >> docs. > > Thanks. > > Having a separate stdout and stderr is great, in fact, just the next thing I > was going to ask about. So both open3 and open4 seem like great candidates. > > Could you take some time to sell open4 over open3? > > The main advantage I see is the greater abstraction, i.e. the spawn method. - you get the child pid returned also with open4 - a command that fails to exec raises and error (note this is sent back from the child fork) - when using the spawn method a great deal of abstraction is provided, not least of which that stdin, stdout, stderr are each handled via a thread so you may provide objects that can handle async output Open4.spawn cmd, 1=>stdout_handler 2=>stderr_handler and it will be passed to the hanlder in an async way the main reason, however, is having the pid - it's hard to kill a proces without it! ;-) that said - if all you require is stdout/stderr stay with the stdlib. regards. -a -- in order to be effective truth must penetrate like an arrow - and that is likely to hurt. -- wei wu wei