[erlang-questions] Executing external commands

Fernando Ipar <>
Mon Feb 12 00:48:10 CET 2007


Hi all.

I'm looking for a way to run external commands in erlang and get it's 
exit code back to erlang.
As far as I understand, os:cmd(Command) only returns the output of 
running the program.

Is there a way to get the exit code from the command, or do I have to 
implement an external program to run these commands and communicate
back and forth with erlang through a port?

What I'm looking for is something like:

os:cmdwithexit(Command,ExitCode),
case ExitCode of
    0 ->
    handleExitOk(Command);
    _ ->
    handleExitError(Command,ExitCode)
end.


Thanks and regards,

Fernando.



More information about the erlang-questions mailing list