If your Akka program creates the process (for example, using ProcessBuilder), then you can capture the output and do whatever you want with it, including routing it into an Akka stream.
If the process is started by some other means then it would be harder - you would need to capture the output as part of launching the program and then use a shell pipe to send it to the Akka process using something like nc. (program | nc hostname port). The Akka process would need to be listening on port (eg, using Akka IO). If the process is already started then you are out of luck unless you have the source code and can do something like System.setOut(new PrintStream(is )). On Saturday, March 19, 2016 at 10:52:55 AM UTC-4, Konrad Malawski wrote: > > That's what bash pipes are for :-) > > -- > Cheers, > Konrad 'ktoso’ Malawski > <http://akka.io>Akka <http://akka.io> @ Lightbend <http://typesafe.com> > <http://lightbend.com> > > On 19 March 2016 at 15:51:10, Arun Sethia ([email protected] > <javascript:>) wrote: > > Thanks. > > My question is more on STDOUT of any other process, specially if it is non > java. > > On Saturday, March 19, 2016 at 6:54:51 AM UTC-5, Konrad Malawski wrote: >> >> Hi there, >> >> Please don't *immediately* cross post your questions here and stack >> overflow >> <http://stackoverflow.com/questions/36096694/intercept-stdout-and-stream-via-akka/36101376#36101376>, >> >> it makes it harder to track answered questions. It's ok to cross post if >> after a while you did not receive an answer, but please don't do so >> immediately. >> >> >> In order to "intercept" stdout in Java you can setOut on the System object. >> It takes a PrintWriter, which we are able to create by wrapping an >> OutputStream "bridge" that Akka Streams provide, here's how: >> >> val is: OutputStream = StreamConverters.asOutputStream() >> .to(Sink.foreach(println)) // your logic pipeline here >> .run() >> System.setOut(new PrintStream(is)) >> >> >> -- >> Konrad >> Akka @ Lightbend >> >> W dniu sobota, 19 marca 2016 01:29:33 UTC+1 użytkownik Arun Sethia >> napisał: >>> >>> Hi, >>> >>> Is it possible to intercept STDOUT of any other process and stream them >>> via akka streaming? >>> >>> Thanks >>> Arun >>> >> -- > >>>>>>>>>> Read the docs: http://akka.io/docs/ > >>>>>>>>>> Check the FAQ: > http://doc.akka.io/docs/akka/current/additional/faq.html > >>>>>>>>>> Search the archives: https://groups.google.com/group/akka-user > --- > You received this message because you are subscribed to the Google Groups > "Akka User List" group. > To unsubscribe from this group and stop receiving emails from it, send an > email to [email protected] <javascript:>. > To post to this group, send email to [email protected] > <javascript:>. > Visit this group at https://groups.google.com/group/akka-user. > For more options, visit https://groups.google.com/d/optout. > > -- >>>>>>>>>> Read the docs: http://akka.io/docs/ >>>>>>>>>> Check the FAQ: >>>>>>>>>> http://doc.akka.io/docs/akka/current/additional/faq.html >>>>>>>>>> Search the archives: https://groups.google.com/group/akka-user --- You received this message because you are subscribed to the Google Groups "Akka User List" group. To unsubscribe from this group and stop receiving emails from it, send an email to [email protected]. To post to this group, send email to [email protected]. Visit this group at https://groups.google.com/group/akka-user. For more options, visit https://groups.google.com/d/optout.
