I'm trying to figure out how to pull the stdout and stderr from a system subprocess in Erlang. (Not to be confused with an Erlang process.) The gotcha is I'm trying to pull the output of the streams independently.
open_port/2 seems to get me most of the way there, however it doesn't seem to provide a way to differentiate between the two streams. There is the stderr_to_stdout option, but that's not what I want; I want to get data from both data streams but be able to distinguish the two streams.
Any suggestions? Thanks.
Update: I'm ideally looking for a solution that will work on both Windows and Linux.
Try this :
Path = filename:join(["./priv", "log", "log_file_name"]),
{ok, F} = file:open(Path, [write]),
group_leader(F, self()),
erlang:display("Anything this process outputs now gets redirected").
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With