[erlang-questions] Running a Unix Subprocess
Csaba Hoch
csaba.hoch@REDACTED
Wed Sep 28 10:34:42 CEST 2016
Here is a short example of starting a process and reading its stdout
with open_port (you need to modify it to pass your own stdin, but it
might be a useful example nevertheless):
http://erlang.org/pipermail/erlang-questions/2007-February/025210.html
Csaba
On Tue, Sep 27, 2016 at 11:34 AM, Ameretat Reith
<ameretat.reith@REDACTED> wrote:
> On Tue, 27 Sep 2016 12:19:53 +0300
> Zachary Kessin <zkessin@REDACTED> wrote:
>
>> Hi all
>>
>> I want to run a sub process that will connect via StdIn and StdOut. Is
>> there an easy way to do this? I had thought to use a port but as the
>> child process was not written with the assumption that it is running
>> inside a port i don't want to have to prepend length bytes onto the
>> inputs and outputs.
>>
>> Is there an easy way to do this in erlang?
>>
>
> User erlang:open_port [1]. Example:
>
> erlang:open_port({spawn_executable, "/bin/cat"}, [eof, exit_status]).
>
> This will open a port and execute "/bin/cat" in it, wait until standard
> input is closed (eof), reply exit status after cat termination
> (exit_status). If you want process get standard input and output of
> caller, pass use_stdio option.
>
>
> 1: http://erlang.org/doc/man/erlang.html#open_port-2
> _______________________________________________
> erlang-questions mailing list
> erlang-questions@REDACTED
> http://erlang.org/mailman/listinfo/erlang-questions
More information about the erlang-questions
mailing list