What the following function will return? ok atom or Cmd?
function_test() -> Cmd = os:cmd(\"ls\"), io:format(\"The result of ls is:~p~n\", [Cmd]).
In Erlang the last expression in your function is returned, in your case that would be the result of io:format which is ok.
io:format
ok
To return Cmd you can simply make it the last expression in your function:
Cmd
function_test() -> Cmd = os:cmd("ls"), io:format("The result of ls is:~p~n", [Cmd]), Cmd.