I have an external exe program that reads from stdin and produces the result. It works as a wc program and reads before EOF. (Or the end of the stream, rather.)
Update: let me add one more explanation: I'm basically trying to write an Erlang pipe.
I can call the program in a batch file, for example echo 339371249625 | LookupProj.exe echo 339371249625 | LookupProj.exe , but I want to be able to transfer data from this file from Erlang gen_server .
I looked at the ports of Erlang, but I have problems making them play well. Here is what I have:
test(InputText) -> P = open_port({spawn, "/ExternEvent/LookupProj.exe"}, [stream, exit_status, use_stdio, stderr_to_stdout, in, out]), IBin = list_to_binary(InputText), %% io:format("~p~n",[I2]), P ! {self(), {command, <<IBin/binary, <<26>>/binary>>}}, %% ASCII 26 = EOF P ! {self(), {eof}}, %% ERROR -- how to close stdin of the cat process? receive B -> io:format("~p",[B]) end.
I tried using the eof flag in open_port without help. (Not sure if this is the correct flag?)
Where am I wrong? Thanks!
source share