Debugging inter-node spawning...

Raimo Niskanen raimo@REDACTED
Mon May 6 09:15:42 CEST 2002


A small objection: 

list_to_pid("<0.0.0>") is a bit hackish, is it not?

Why not use whereis(user) instead? Like in:

	RP = rpc:call(per@REDACTED, erlang, whereis, [user]),
	io:format(RP,"Hello World !\n",[]).

Since the process with the registered name 'user' is the one handling
user I/O.

/ Raimo Niskanen, Erlang/OTP, Ericsson AB



Per Bergqvist wrote:
> 
> Hi Harley,
> 
> No, io:format is not printf.
> If you check io:format/3 it takes an i/o device pid as the first
> argument. If the argument is omitted io:format will use the group
> leader.
> 
> To do output on the remote node do either:
> a)
> RP = rpc:call(per@REDACTED,erlang,list_to_pid,["<0.0.0>"]),
> io:format(RP,"Hello World !\n",[]).
> b)
> LP = erlang:group_leader(),
> RP = rpc:call(per@REDACTED,erlang,list_to_pid,["<0.0.0>"]),
> erlang:group_leader(RP,self()),
> io:format("Hello World !\n"),
> erlang:group_leader(LP,self()).
> 
> To do low level output use erlang:display.
> 
> /Per
> 
> 
> 
> > On Wed, 1 May 2002, Harley Gorrell wrote:
> > > Spawning on the node works just fine.  What should I look
> > > at to figure out what is wrong?
> >
> >    I received two replies, to this note which also went to
> > this list.  Thanks Andreas and Lennart!
> >
> >    After reading them, I checked again that the cookie was
> > correct (is was) and tried out the 'net_adm:ping' function
> > which I hadnt known about.  With ping I could then see a
> > non-null list from nodes(). So I knew erlang was setup ok.
> >
> >    After a bit more tinkering, I found that the call was
> > indeed making the round trip, but the output of 'io:format'
> > was appearing on the console of the spawning node.  I was
> > thinking that the output would appear on the remote node.
> >
> >    Here is an example. 'echo:hi/1' is loaded on 'foo2@REDACTED'
> > with 'c(echo)'. From a new erl, I spawn the function and
> > the output appears locally.
> >
> > --------------------
> >
> > $erl -sname foo1
> > Erlang (BEAM) emulator version 5.1 [source]
> >
> > Eshell V5.1  (abort with ^G)
> > (foo1@REDACTED)1> spawn(foo2@REDACTED,echo,hi,[foo2]).
> > hi2 'foo2'
> > <38.48.0>
> > (foo1@REDACTED)2>
> >
> > --------------------
> >
> >    Moral: 'io:format' is not 'printf'.
> >
> > thanks everyone,
> > harley.
> >
> =========================================================
> Per Bergqvist
> Synapse Systems AB
> Phone: +46 709 686 685
> Email: per@REDACTED



More information about the erlang-questions mailing list