If you do not want to use Porcelain, which has an executable dependency, you can use a port, for example:
def long do port = Port.open({:spawn_executable, /path/to/command"}, [:stderr_to_stdout, :binary, :exit_status, args: ["arg1"]]) stream_output(port) end defp stream_output(port) do receive do {^port, {:data, data}} -> Logger.info(data) # send to phoenix channel stream_output(port) {^port, {:exit_status, 0}} -> Logger.info("Command success") {^port, {:exit_status, status}} -> Logger.info("Command error, status
source share