[erlang-questions] set node name and escript rpc_call to anothernode

Ali Yakout ali.yakout@REDACTED
Sun Apr 13 10:54:11 CEST 2008


Hi Ralph,
 
I know its too late to reply :), but I noticed that no one answered
this.
Just want to inform you that I do the same thing you wish to do using
escript and shell script.
 
First make sure you start the nodes with the same cookie 
$ erl -sname mynode -setcookie mycookie ...
 
The escript should look like:
 
    #!/usr/bin/env escript
    %% -*- erlang -*-
 
    main(_Args) ->
        net_kernel:start([shell, shortnames]),
        erlang:set_cookie(node(), mycookie),
        rpc:call('mynode@REDACTED' <mailto:'mynode@REDACTED'> ,
conf_server, reload, []).

I have tried this script with sasl in my .erlang as you do and got the
same result "started_at: nonode@REDACTED", seems that the erlang shell is
started before the escript is executed.

Another way is to do it in shell script where we needn't hard code the
hostname as above, and the sasl will show "started_at: shell@REDACTED
<mailto:shell@REDACTED> "

    #! /bin/sh -fup

    NODENAME=\'mynode@$HOSTNAME\'
    erl -sname shell -setcookie mycookie > /dev/null << !
        rpc:call($NODENAME, conf_server, reload, []).
        halt().
    !


OR

    #! /bin/sh -fup

    NODENAME=\'mynode@$HOSTNAME\'
    CMD=rpc:call\($NODENAME,conf_server,reload,[]\).
    erl -sname shell -setcookie mycookie -eval $CMD -s init stop

 

Regards, 
Ali Yakout 


________________________________

From: erlang-questions-bounces@REDACTED
[mailto:erlang-questions-bounces@REDACTED] On Behalf Of db
Sent: Friday, February 29, 2008 1:37 AM
To: erlang-questions@REDACTED
Subject: [erlang-questions] set node name and escript rpc_call to
anothernode


Would I be able to make rpc_call to another node from escript?  When I
start escript, erl node which escript start, is called nonode@REDACTED
Is there a way for this node to join the pool, so I can perform rpc
call?

I have tried set the following in my escript:
net_kernel:start([foobar, shortnames])

When I ran the escript,  sasl is automatically started up.  This is my
default setup in .erlang file.  Even though, with
net_kernel:start([foobar, shortnames]) in escript, sasl application is
running on nonode@REDACTED, but the node never assigned the name "foobar".
Why is this?

Here is the sasl output:

=PROGRESS REPORT==== 28-Feb-2008::15:44:03 ===
          supervisor: {local,sasl_sup}
             started: [{pid,<0.32.0>},
                       {name,sasl_safe_sup},
                       {mfa,
                           {supervisor,start_link,
                               [{local,sasl_safe_sup},sasl,safe]}},
                       {restart_type,permanent},
                       {shutdown,infinity},
                       {child_type,supervisor}]

=PROGRESS REPORT==== 28-Feb-2008::15:44:03 ===
          supervisor: {local,sasl_sup}
             started: [{pid,<0.35.0>},
                       {name,release_handler},
                       {mfa,{release_handler,start_link,[]}},
                       {restart_type,permanent},
                       {shutdown,2000},
                       {child_type,worker}]

=PROGRESS REPORT==== 28-Feb-2008::15:44:03 ===
         application: sasl
          started_at: nonode@REDACTED

=PROGRESS REPORT==== 28-Feb-2008::15:44:03 ===
          supervisor: {local,net_sup}
             started: [{pid,<0.39.0>},
                       {name,erl_epmd},
                       {mfa,{erl_epmd,start_link,[]}},
                       {restart_type,permanent},
                       {shutdown,2000},
                       {child_type,worker}]

=PROGRESS REPORT==== 28-Feb-2008::15:44:03 ===
          supervisor: {local,net_sup}
             started: [{pid,<0.40.0>},
                       {name,auth},
                       {mfa,{auth,start_link,[]}},
                       {restart_type,permanent},
                       {shutdown,2000},
                       {child_type,worker}]

=PROGRESS REPORT==== 28-Feb-2008::15:44:03 ===
          supervisor: {local,net_sup}
             started: [{pid,<0.41.0>},
                       {name,net_kernel},
 
{mfa,{net_kernel,start_link,[[foobar,shortnames]]}},
                       {restart_type,permanent},
                       {shutdown,2000},
                       {child_type,worker}]

=PROGRESS REPORT==== 28-Feb-2008::15:44:03 ===
          supervisor: {local,kernel_sup}
             started: [{pid,<0.38.0>},
                       {name,net_sup_dynamic},
                       {mfa,
                           {erl_distribution,start_link,
                               [[foobar,shortnames]]}},
                       {restart_type,permanent},
                       {shutdown,1000},
                       {child_type,supervisor}]

-- 
rk

That which we persist in doing becomes easier for us to do; not that the
nature of the thing itself is changed, but that our power to do is
increased.
-Ralph Waldo Emerson 
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://erlang.org/pipermail/erlang-questions/attachments/20080413/603183d9/attachment.htm>


More information about the erlang-questions mailing list