[erlang-questions] managing subprocesses
Michael Truog
mjtruog@REDACTED
Thu May 30 22:10:01 CEST 2013
If you want to do it manually, you would be using:
http://www.erlang.org/doc/man/erlang.html#open_port-2
Note that you can also do something like (if you only care about the exit code):
shell(Command, Arguments) ->
CommandSuffix = " && echo 0 || echo 1",
[Result | _] = os:cmd(lists:flatten(
io_lib:format(Command ++ CommandSuffix, Arguments))),
if
Result =:= $0 ->
ok;
Result =:= $1 ->
io:format("\"~s\" failed!~n", [io_lib:format(Command, Arguments)]),
error
end.
On 05/30/2013 12:52 PM, Timo Schrappe wrote:
> Hello,
>
> I am wondering that there isn't a great way for managing and parsing subprocesses (through os:cmd/1) and their output.
> I spent some time with google and found erlexec which basically will do my job here. But it feels a bit cheesy to use an external module (or is it called application in erlang?) to use such a fundamental functionality.
>
> I want to manage some shell scripts which will start some e.g. daemons.
>
>
> What is the erly way to do that kind of things? Im specially interested in the exit code from the bash scripts.
>
>
> - Timo
> _______________________________________________
> erlang-questions mailing list
> erlang-questions@REDACTED
> http://erlang.org/mailman/listinfo/erlang-questions
>
More information about the erlang-questions
mailing list