[erlang-questions] gen_server:cast from escript

YuanZhiqian <>
Mon Mar 21 07:00:35 CET 2016

Hi Park,
  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.

Date: Thu, 10 Mar 2016 12:35:21 +0900
Subject: Re: [erlang-questions] gen_server:cast from escript

You didn't connect to target node.Have to call net_adm:ping(Node) first to connect.

On Tue, Mar 8, 2016 at 3:47 PM, YuanZhiqian <> wrote:

Hi guys,
  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? 

#!/usr/bin/env escript
%%! -name  -setcookie budget_keeper
main(Argv) ->    {Node, File} = case Argv of                       [] ->                           {'', "cache"};                       [F] ->                           {'', F};                       [N, F] ->                           {N, F}                   end,    io:format("~p ~p ~p ~p~n", [node(), erlang:get_cookie(), Node, File]),    gen_server:cast({bk_main, Node}, {dump_data, File}).

As shown above, the target process is called "bk_main" which is on the node '', 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.
Best regardsZhiqian 		 	   		  


erlang-questions mailing list


Park, Sungjin-------------------------------------------------------------------------------------------------------------------Peculiar travel suggestions are dancing lessons from god.  -- The Books of Bokonon-------------------------------------------------------------------------------------------------------------------
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://erlang.org/pipermail/erlang-questions/attachments/20160321/a97ec1b6/attachment.html>

More information about the erlang-questions mailing list