[erlang-questions] open_pipe({spawn, "cat"}) --- how to close stdin of cat?

C K Tan cktan@REDACTED
Sun Mar 1 10:45:53 CET 2009


Hi all,

I am tryinng to use port to open a program that reads until EOF from
stdin, and then write results to stdout ... i.e. something like the
unix wc command. I can't figure out how to close the stdin of the
spawned process:

wc(InputText) ->
    P = open_port({spawn, "wc"}, [stream, exit_status, use_stdio,
                            stderr_to_stdout, in, out, eof]),
    P ! {self(), {command, "hello world"}},
    P ! {self(), {eof}},   %% ERROR -- how to close stdin of the cat process?
    receive {P, X} -> X end.
	
Also, where can I find detailed documentation on open_port?

Appreciate any help.

Thanks,
-cktan



More information about the erlang-questions mailing list