<html>
<head>
<style><!--
.hmmessage P
{
margin:0px;
padding:0px
}
body.hmmessage
{
font-size: 12pt;
font-family:΢ÈíÑźÚ
}
--></style></head>
<body class='hmmessage'><div dir='ltr'>Hi Park,<div><br></div><div>  Thanks a lot. That works! I wonder, however, why it is needed to connect to target node manually in an escript, while in a shell I can directly execute gen_server:cast to another target node.</div><div><br></div><div>Regards</div><div>Zhiqian<br><br><div><hr id="stopSpelling">Date: Thu, 10 Mar 2016 12:35:21 +0900<br>Subject: Re: [erlang-questions] gen_server:cast from escript<br>From: jinni.park@gmail.com<br>To: on-your-mark@hotmail.com<br>CC: erlang-questions@erlang.org<br><br><div dir="ltr">You didn't connect to target node.<div>Have to call net_adm:ping(Node) first to connect.</div><div><br></div><div><br></div></div><div class="ecxgmail_extra"><br><div class="ecxgmail_quote">On Tue, Mar 8, 2016 at 3:47 PM, YuanZhiqian <span dir="ltr"><<a href="mailto:on-your-mark@hotmail.com" target="_blank">on-your-mark@hotmail.com</a>></span> wrote:<br><blockquote class="ecxgmail_quote" style="border-left:1px #ccc solid;padding-left:1ex;">


<div><div dir="ltr">Hi guys,<div><br></div><div>  I was trying to call gen_server:cast from a escript file, everything that used to work well in erl shell won't work in escript, I have no idea what made the difference, here is the code, could anyone help me to find a clue? </div><div><br></div><div><br></div><div><br></div><div><div>#!/usr/bin/env escript</div><div><br></div><div>%%! -name bk@test -setcookie budget_keeper</div><div><br></div><div>main(Argv) -></div><div>    {Node, File} = case Argv of</div><div>                       [] -></div><div>                           <b>{'<a href="mailto:budget_keeper@127.0.0.1" target="_blank">budget_keeper@127.0.0.1</a>', "cache"</b>};</div><div>                       [F] -></div><div>                           {'<a href="mailto:budget_keeper@127.0.0.1" target="_blank">budget_keeper@127.0.0.1</a>', F};</div><div>                       [N, F] -></div><div>                           {N, F}</div><div>                   end,</div><div>    io:format("~p ~p ~p ~p~n", [node(), erlang:get_cookie(), Node, File]),</div><div>    gen_server:cast({bk_main, Node}, {dump_data, File}).</div></div><div><br></div><div><br></div><div><br></div><div>As shown above, the target process is called "bk_main" which is on the node '<a href="mailto:budget_keeper@127.0.0.1" target="_blank">budget_keeper@127.0.0.1</a>', I have run the same code in erl shell, and bk_main can get the notice, but nothing happened when I ran the same code in this script.</div><div><br></div><div>Best regards</div><div>Zhiqian</div>                                           </div></div>
<br>_______________________________________________<br>
erlang-questions mailing list<br>
<a href="mailto:erlang-questions@erlang.org">erlang-questions@erlang.org</a><br>
<a href="http://erlang.org/mailman/listinfo/erlang-questions" rel="noreferrer" target="_blank">http://erlang.org/mailman/listinfo/erlang-questions</a><br>
<br></blockquote></div><br><br clear="all"><div><br></div>-- <br><div class="ecxgmail_signature">Park, Sungjin<div>-------------------------------------------------------------------------------------------------------------------</div><div>Peculiar travel suggestions are dancing lessons from god.</div><div>  -- The Books of Bokonon</div><div>-------------------------------------------------------------------------------------------------------------------</div></div>
</div></div></div>                                      </div></body>
</html>