[erlang-questions] Erlang module for "controlling" (linux/unix) commands?

Tuncer Ayaz tuncer.ayaz@REDACTED
Wed Sep 8 16:22:55 CEST 2010

On Wed, Sep 8, 2010 at 4:09 PM, Boris Mühmer wrote:
> Is there a module for controlling (linux/unix) "shell" commands?
> I am looking for something more "special" than "os:cmd/1",
> because I need to get the exit code of the command.

Take a look at erlang:open_port/2.

call erlang:open_port({spawn_executable, Command}, PortSettings)
where PortSettings at least contains the exit_status option  You might
also have to pass the use_stdio and {line, L} options.

The exit code will be delivered as a message:
    {Port, {data, ...}} -> ...
    {Port,{exit_status,Status}} -> ...

More information about the erlang-questions mailing list