Use env variables with System.cmd or Ports?

And if anyone comes to this thread looking for the same thing i was, here is how you also get the status code:

iex(18)> port = Port.open({:spawn, "/bin/echo $GOPATH"}, [:binary, :exit_status])
#Port<0.20>
iex(19)> flush
{#Port<0.20>, {:data, "/Users/rlthompson/go\n"}}
{#Port<0.20>, {:exit_status, 0}}
:ok
3 Likes