how to capture io:format's output using ei?

Ulf Wiger ulf@REDACTED
Tue Oct 18 21:49:23 CEST 2005


Den 2005-10-18 19:25:16 skrev Serge Aleynikov <serge@REDACTED>:

> Interesting...
>
> Though in my case even if I use "~n" then nothing gets returned.  If I  
> use "\n" then, 'ok' gets returned, however, a "Test string\n" gets  
> printed in the shell window of the tt@REDACTED node:
>
> devlinuxpro2> ./erl_call -sname tt@REDACTED -a 'io format ["Test  
> string~n"]'
> devlinuxpro2>
>
> (tt@REDACTED)9>
> (tt@REDACTED)9>
>
> devlinuxpro2> ./erl_call -sname tt@REDACTED -a 'io format ["Test  
> string\n"]'
> ok          <-- the result of a call got printed
> devlinuxpro2>
>
> (tt@REDACTED)9> Test string\n     <-- this is printed in the shell
> (tt@REDACTED)9>

Yes, this was exactly what I got too.
Something in the chain chokes on the tilde. Remove it, and you
can get a printout of sorts, but io:format/2 without tildes is
a bit limited...


> So, the original question still stands: could you tell how to redirect  
> the output when using the ei's rpc call?

I have not looked into ei at all. The standard way to make sure that
io gets executed on the remote node is to either set the group leader
of the remote process to some standard group leader on the remote
node (per default in an rpc:call(), the group leader is the calling
process, which makes sense if the remote node e.g. doesn't have io
capabilities).

If you specify the destination in the io:format/3 call:

io:format(user, "Hello~n", [])

then the locally registered process 'user' will be used to
handle the output. Note that on a node started with -noshell,
whereis(user) -> undefined. This means nothing will get
printed ;-), but rpc:call(Remote, io, format, [user,"...",[]])
will still return 'ok'.

Again, this is how it works with normal rpc. Don't know about ei.

/Uffe
-- 
Ulf Wiger



More information about the erlang-questions mailing list