Erl.exe input
Aldo Calpini
dada.list@REDACTED
Fri Jun 14 14:43:47 CEST 2002
Bengt Kleberg wrote:
> admittedly the erlang program above is a bit simplistic. please feel
> free to make it more robust/portable by appending something like:
>
> init:stop().
that's fine for input given to erlang. but there's still a (maybe
related) problem with STDIN on windows.
consider this little program called pipe.erl (I didn't wrote it, was
probably posted to this mailing list):
-module(pipe).
-compile(export_all).
start() ->
spawn(pipe,init,[]).
init() ->
Port = open_port({fd, 0, 1},[eof]),
loop(Port).
loop(Port) ->
receive
{Port, {data, What}} ->
Port ! {self(), {command, What}},
loop(Port);
{Port, eof} ->
halt()
end.
this should prints on STDOUT what it receives on STDIN. it all goes
well in this case:
;echo hello >inputfile
;type inputfile | erl -s pipe -nouser
hello
but it doesn't work this way (again, I have to manually stop erlang):
;erl -s pipe -nouser <inputfile
hello
BREAK: (a)bort (c)ontinue (p)roc info (i)nfo (l)oaded
(v)ersion (k)ill (D)b-tables (d)istribution
the two should be perfectly equivalent, but they're not.
I'm pretty sure this works on Linux because that's how several programs
from the Doug Bagley's Shootout (http://www.bagley.org/~doug/shootout)
works.
but the same programs ported on windows (http://dada.perl.it/shootout)
timed out whenever they try to read from STDIN.
so I still think there's a bug somewhere ;-)
cheers,
Aldo
__END__
$_=q,just perl,,s, , another ,,s,$, hacker,,print;
More information about the erlang-questions
mailing list