Is Open4 not win32 compatable? With all win32ole hooks, I'm suprised
no one has tackled this yet.

Ara, you helped me a while back with spawning processes in win32,
catching pids and error levels.

--just assumed if I could install it as a gem, it would work.



Microsoft Windows XP [Version 5.1.2600]
(C) Copyright 1985-2001 Microsoft Corp.

C:\Documents and Settings\d0t1q>gem install open4
Attempting local installation of 'open4'
Local gem file not found: open4*.gem
Attempting remote installation of 'open4'
Updating Gem source index for: http://gems.rubyforge.org
Successfully installed open4-0.7.0

C:\Documents and Settings\d0t1q>irb
irb(main):001:0> require 'open4'
=> false
irb(main):002:0> Open4.spawn "echo", :stdin => "hello"
NameError: uninitialized constant Fcntl::F_SETFD
        from c:/ruby/lib/ruby/gems/1.8/gems/open4-0.7.0/lib/open4.rb:19:in `pope
n4'
        from c:/ruby/lib/ruby/gems/1.8/gems/open4-0.7.0/lib/open4.rb:263:in `spa
wn'
        from c:/ruby/lib/ruby/1.8/timeout.rb:48:in `timeout'
        from c:/ruby/lib/ruby/gems/1.8/gems/open4-0.7.0/lib/open4.rb:262:in `spa
wn'
        from (irb):2
irb(main):003:0>


On 9/20/06, ara.t.howard / noaa.gov <ara.t.howard / noaa.gov> wrote:
> 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
>
>