Catching result of calling System.cmd?

Hello

I am trying to run a command line by targeting a library that do some calculations in return results back.
like: {output, _} = System.cmd("ngspice", ["-b", file_path])

it works fine, and I can read results back in output however, when there is a library related error, the error is not return back in output above, although I can see the error result in the phoenix log.

For example:, this output was not returned back but only seen in phoenix server log:|

run simulation(s) aborted
Error(parse.c--checkvalid): vv1#branch: no such vector.

How can I handle that? why error wasn’t retrieved back as a result of using System.cmd ?

You can use the :stderr_to_stdout option to get the stderr and stdout combined, you can’t select between them. Also you can take a look at the second element of the tuply (you currently ignore it), some programms tell you quite a lot in this little integer…

1 Like

Thanks, that’s what I needed!