Long running process notification

I am newcomer at elixir. I am trying to know how I cat reseive some output from long runinng process. Fo example: System.cmd “ping”, [“abc.com”, “-n”, “600”] (-> ping abc.com -n 600 - for Misrosoft Windows). This command will running 600 times. I receive correct output only when this command finish - only after 10 minutes. But I would like to stop it’s runninig when 5-th error message come. Could you advice time some example/code ?

You can either use the Port module to drive your command or you can use the porcelain package which is a wrapper around Port and keeps some nasty edge cases away from you.

Thanks for you answer. I read this documentation. Could you explain how can I receive stdout at runtime?
Porcelain require additional binary file.

In a Port you can just receive the messages.

Didn’t know about that. It was recommended elsewhere for a similar problem, I never used it but Ports directly. And to be honest, so far only in an Erlang environment, not in elixir.

edit From a quick glance of porcelains documentation, I do think that Porcelain.spawn/3 is what you are searching for. You just specify a pid that shall handle stdout and -err in the thrird argument and then go for it… Another way were to specify :stream in the options and then to read that stream, maybe a bit easier as a start. But for the details you’ll have to ask more refined questions.

I’m not sure though, what you meant by “needing an additional binary file”, perhaps you are misreading something from the docs?

Thats an example project which showcases and demonstrates how porcelain works. It uses some tool called goon to do this. You can use porcelain without it.