how to capture io:format's output using ei?
Serge Aleynikov
serge@REDACTED
Wed Oct 19 13:50:15 CEST 2005
Uffe,
Thank you for your comments. Perhaps someone from the ei's OTP support
team can shed some light on this issue. The open question is:
As Uffe pointed out we can register a local process 'user' using ei's
ei_publish() function (along with bind() and listen() on an open
socket). However, then it forces us to use io:format(user, Format,
Args) function on the server node, and if I understand this correctly,
the output of io:format/2 won't be sent to the remote C client caller.
Is there a "correct" (i.e. preferred) way of doing this in C, so that
output of both io:format/[2,3] could be captured at the remote node
invoking the ei_rpc(), and that io:format/[2,3] would understand tildes?
Thanks.
Serge
Ulf Wiger wrote:
> 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
More information about the erlang-questions
mailing list