From: Andrea Dallera Date: 2012-06-28T23:36:12+09:00 Subject: Re: Asynchronous IO --_=__=_XaM3_.1340893875.2A.678332.42.19737.52.42.007.162786683 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable =C2=A0This is far from a clean solution, mind you:=0A=0A=C2=A0 =C2=A0 pip= e =3D=C2=A0IO.popen("command", "options")=0A=C2=A0 =C2=A0 Thread.new do=0A= =C2=A0 =C2=A0 =C2=A0 while(true)=0A=C2=A0 =C2=A0 =C2=A0 =C2=A0 p pipe.get= s=C2=A0 =C2=A0 =C2=A0 =C2=A0=C2=A0=0A=C2=A0 =C2=A0 =C2=A0 end=0A=C2=A0 =C2= =A0 end=0A=C2=A0 =C2=A0 pipe.puts("I'm writing this on the pipe")=0A=0AYo= u should see the process's output in your STDOUT.=0A=0AAndrea=0A=C2=A0=0A= --=0A=C2=A0=0Ahttp://usingimho.wordpress.com=0Ahttp://github.com/bolthar=0A= Da: "F1 dreamer" lists@ruby-forum.com=0AA: ruby-talk@ruby-lang.org=0ACc: = =0AData: Thu, 28 Jun 2012 23:12:28 +0900=0AOggetto: Asynchronous IO=0A=0A= > I have found quite a bit on the web regarding asynchronous IO, but=0A> = nothing really works the way I expected it to in my case.=0A> =0A> I'm ne= w to this but herewith my question anyway:=0A> =0A> Currently I'm using O= I.popen to open a new pipe to another process, and=0A> I feed commands to= it; but sometimes the other process could run for=0A> multiple minutes b= efore closing the pipe; and only at that stage can I=0A> then see the out= put. Now, what I really need is to see the output of the=0A> process as i= t writes to stdout already and not only when closing the=0A> pipe?=0A> =0A= > Ta.=0A> =0A> -- =0A> Posted via http://www.ruby-forum.com/.=0A> --_=__=_XaM3_.1340893875.2A.678332.42.19737.52.42.007.162786683 Content-Type: text/html; charset=utf-8 Content-Transfer-Encoding: quoted-printable =0A
=0A
 This is far from a clean solution,= mind you:

    pipe =3D IO.popen(= "command", "options")
    Thread.new do
      while(true)
        = p pipe.gets        
    &nbs= p; end
    end
    pipe.put= s("I'm writing this on the pipe")

You should see= the process's output in your STDOUT.

Andrea
 
--
 
http://usingimho.wo= rdpress.com
http://github.com/bolthar


=0A
Da: "F1 dreamer" lists@ruby-forum.com
=0A
A: ruby-talk@ruby-lang.org
=0A
Cc: <= /div>=0A
Data: Thu, 28 Jun 2012 23:12:28 +0900=0A
: Asynchronous IO
=0A
=0A
&= gt; I have found quite a bit on the web regarding asynchronous IO, but
> nothing really works the way I expected it to in my case.
>
> I'm new to this but herewith my question any= way:
>
> Currently I'm using OI.popen to open = a new pipe to another process, and
> I feed commands to it; = but sometimes the other process could run for
> multiple min= utes before closing the pipe; and only at that stage can I
>= then see the output. Now, what I really need is to see the output of the=
> process as it writes to stdout already and not only when = closing the
> pipe?
>
> Ta.
=
>
> --
> Posted via http://www.ruby-f= orum.com/.
>
=0A
=0A --_=__=_XaM3_.1340893875.2A.678332.42.19737.52.42.007.162786683--