[erlang-questions] Remote module compilation

Alin Popa <>
Tue May 26 13:21:27 CEST 2009


Ok, I found the solution:

(thanks to http://www.trapexit.org/Remote_Code_Load)

On the 1st node:

*1> {Mod, Bin, File} = code:get_object_code(tes).

2> {Replies, _} = rpc:call('',erlang,load_module, [Mod, Bin]).
{module,area_server1}
*
and now, simply run:

*Pid = spawn('', test, test_fun, []).*
*<5476.55.0>*


On Tue, May 26, 2009 at 2:13 PM, Alin Popa <> wrote:

> I forgot to say that the file is not present on 2nd node...so, maybe I
> could not use code:load_binary.....
>
>
> On Tue, May 26, 2009 at 1:59 PM, Alin Popa <> wrote:
>
>> Hi,
>>
>> It is possible to send remote a module source and that one to be compiled
>> there ?
>> Or, I have a compiled module but is not loaded on the remote process; is
>> it possible to send it there, or I should express load it on the remote
>> process?
>> This is my test module:
>>
>> *-module(test).
>> -export([test_fun/0]).
>>
>> test_fun() ->
>>    io:format("Hello ~p~n",["World"]).*
>>
>>
>> now, start one erlang process(on 1st machine):
>>
>> *erl -name  -setcookie test123*
>>
>> ... start other erlang process (on 2nd machine):
>> *erl -name  -setcookie test123*
>>
>> In 1st node:
>>
>> *1> c(test).
>> {ok, test}
>> 2>
>> *
>> In 2nd node, do nothing...
>>
>> In the 1st node:
>>
>> *2> spawn('', test, test_fun, []).*
>>
>> *Error in process <0.49.0> on node '' with exit value:
>> {undef,[{test,test_fun,[]}]}*
>>
>> (Which is normal, I think)
>>
>>
>> So, somewhere in this *flow, *something like *remote module loading* can
>> be done ?
>>
>> Thanks.
>>
>> --
>> Regards,
>>
>> Alin
>>
>>
>
>
> --
> Best Regards,
>
> Alin
>
>


-- 
Best Regards,

Alin
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://erlang.org/pipermail/erlang-questions/attachments/20090526/c515d68c/attachment.html>


More information about the erlang-questions mailing list