[erlang-questions] escript and epmd

Fredrik Svahn fredrik.svahn@REDACTED
Thu Sep 20 20:46:53 CEST 2007


Perhaps something on the lines of:

#!/usr/bin/env escript

main(_) ->
   os:cmd("epmd&"),
   net_kernel:start([foo, shortnames]),
   erlang:set_cookie(node(), foo),
   case net_adm:ping( some_other_node@REDACTED) of
     pong -> io:format("~p~n",[nodes()]);
     pang -> io:format("nok~n")
   end.

BR /Fredrik

On 9/19/07, Stefan Strigler <steve@REDACTED> wrote:
>
> Hi, next question :)
>
> How can I make sure that epmd is running when using escript. I want to
> start a named node from within escript and ping some other node like
> this:
>
> #!/usr/bin/env escript
>
> main(_) ->
>   net_kernel:start([foo, shortnames]),
>   erlang:set_cookie(some_random_cookie),
>   case net_adm:ping(some_other_node) of
>     pong -> ...
>     pang -> %% spawn some_other_node
>       ...
>   end.
>
> But if epmd isn't running already I get:
>
> =INFO REPORT==== 19-Sep-2007::18:50:36 ===
> Protocol: "inet_tcp": register error: {{badmatch,{error,econnrefused}},
>                                        [{inet_tcp_dist,listen,1},
>                                         {net_kernel,start_protos,4},
>                                         {net_kernel,start_protos,3},
>                                         {net_kernel,init_node,2},
>                                         {net_kernel,init,1},
>                                         {gen_server,init_it,6},
>                                         {proc_lib,init_p,5}]}
> escript: script failed with error reason function_clause
>
>
>
> Any help appreciated, Steve
>
> _______________________________________________
> erlang-questions mailing list
> erlang-questions@REDACTED
> http://www.erlang.org/mailman/listinfo/erlang-questions
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://erlang.org/pipermail/erlang-questions/attachments/20070920/13657d7f/attachment.htm>


More information about the erlang-questions mailing list