[erlang-questions] Running multiple commands like os:cmd/1

Gleb Peregud gleber.p@REDACTED
Thu Dec 27 12:08:40 CET 2012

On Thu, Dec 27, 2012 at 1:25 AM, Siraaj Khandkar <siraaj@REDACTED> wrote:
> Why does it have to be a single shell? What is wrong with multiple ports?

It's because I want to preserve changes in env variables between calls
(see requirement 4), since I want to be able to run commands like ".
/opt/erlang/r15b/activate" to prepare environment for further
commands. Think of a sequence of commands run by CI server.

>> 1) I want it to work asynchronously (i.e. I start a command and I get
>> it's results streamed to a process as it happens);
> If it really has to be a single shell, you can background each command
> and you can tell when each will finish, but I don't know how would you
> distinguish which output came from where.

It's exactly the problem I am facing.

>> open_port({spawn, "/bin/sh -s -"}, [line]) with port_command/2 doesn't
>> satisfy requirement 2.
> How about open_port with 'exit_status' and call erlang:now/0 when receiving
> {Port, {exit_status, ExitCode}} messages?

One open_port can produce just one exit_status message. Not sure what
you mean here.

More information about the erlang-questions mailing list