I have some tests where I shell out to execute a Java app using System.cmd/3. This app is very verbose and writes to STDOUT, is there a way to silence it?
I’m looking for something like capture_log, but capture_io only seems to silence IO, but not the output from system commands.
Usually all output of the called command shut be captured and returned to you and nothing printed to stdout… Can you therefore show an example of a call that actually prints to stdout?
By default it’s just returned, so you can ignore it. Can you give an example usage via the iex terminal with some posix command or so to act as a demonstration of what it does and explain what you want it to do instead?
It turns out that this Java app was writing both to STDOUT and STDERR, so the solution given by @wojtekmach fixed the issue, redirecting STDERR to STDOUT made it silent as the output is just returned, not printed.
If you want to capture them separately, you need to use Ports or one of the many portwrapper libraries like porcelain or rambo.
Be aware though, that both of them require additional programs on your system to wrap the actual command. I’m not sure if they get delivered/bundled with the package or if they need to be installed separately.