List Info

Thread: Popen implemented, give it a try




Popen implemented, give it a try
user name
2007-06-12 20:27:25
Thanks to Bill Kelly for a lot of suggestions and a lot of research.

You can now do this:

module MyHandler
  def receive_data data
 ;   puts data
 ; end
  def unbind
    puts "Unbound"
  end
end

EM.run {
  EM.popen "ls -ltr", MyHandler
}

EventMachine#popen runs the given command in a subprocesses connected to the main reactor loop with a full-duplex socketpair. Use EventMachine::Connection#get_pid to get the kernel PID of the subprocess in case you need it. The handler module or class works just like any other. You can imagine that you're connected to a TCP server. Nothing is different.

Good luck and if you try it, please leave feedback here.
Re: Popen implemented, give it a try
country flaguser name
United States
2007-06-12 21:21:02
From: Francis Cianfrocca
>
> module MyHandler
>   def receive_data data
>     puts data
>   end
>   def unbind
>     puts "Unbound"
>   end
> end
> 
> EM.run {
>   EM.popen "ls -ltr", MyHandler
> }
>

Thanks, Francis !!

This will be ideal for my current project.


Regards,

Bill



_______________________________________________
Eventmachine-talk mailing list
Eventmachine-talkrubyforge.org
http://rubyforge.org/mailman/listinfo/eventmachine-talk

[1-2]

about | contact  Other archives ( Real Estate discussion Medical topics )