Displaying messages in a remote node IO
Vladimir Sekissov
svg@REDACTED
Fri Dec 20 22:22:17 CET 2002
Good day,
As in Unix all IO is sent to group leader process.
There is a trick I've got from:
http://www.erlang.org/ml-archive/erlang-questions/200205/msg00004.html
If we on Node2:
RP = rpc:call(Node1,erlang,list_to_pid,["<0.0.0>"]),
erlang:group_leader(RP,self()),
io:format("Hello World !\n").
and all output from your process will be redirected to Node1.
Best Regards,
Vladimir Sekissov
erlang>
erlang> Thank you for all your responses.
erlang>
erlang> I have started the code below in Node 1.
erlang> I'd like to send a message from Node 2 to Node 1 and display it in Node 1
erlang> I don't figure out what should I modify in this code to do this.
erlang>
erlang> %%%%%%%%%%%%%%%%
erlang>
erlang> -module(logger).
erlang> -export([start/0, stop/0]).
erlang>
erlang>
erlang> start() ->
erlang> spawn(fun() -> init() end).
erlang>
erlang> stop() ->
erlang> logger ! {stop, self()}.
erlang>
erlang> init() ->
erlang> register(logger, self()),
erlang> process_flag(trap_exit, true),
erlang> loop().
erlang>
erlang> loop() ->
erlang> receive
erlang> {call, Caller, Msg} ->
erlang> {self(), sender, Msg},
erlang> io:format('Logger closed ~w ~n', Msg)
erlang> loop();
erlang> {stop, Caller} ->
erlang> io:format('Logger closed ~n'),
erlang> exit(normal)
erlang> end.
erlang>
erlang> %%%%%%%%%%%%
erlang>
erlang> Thanks,
erlang> Eduardo Figoli
erlang> INSwitch Solutions
erlang>
erlang>
erlang>
erlang>
More information about the erlang-questions
mailing list