Perhaps something on the lines of:<span class="q"><br><br>#!/usr/bin/env escript<br> <br>main(_) -><br></span>   os:cmd("epmd&"),<span class="q"><br>   net_kernel:start([foo, shortnames]),<br></span>   erlang:set_cookie(node(), foo),
<br>   case net_adm:ping(
some_other_node@host) of<br>     pong -> io:format("~p~n",[nodes()]);<br>     pang -> io:format("nok~n")<br>   end.<br><br>BR /Fredrik<span id="e_115242acc4a25dc9_5"></span><br><br><div><span class="gmail_quote">
On 9/19/07, <b class="gmail_sendername">Stefan Strigler</b> <<a href="mailto:steve@zeank.in-berlin.de">steve@zeank.in-berlin.de</a>> wrote:</span><blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;">
Hi, next question :)<br><br>How can I make sure that epmd is running when using escript. I want to<br>start a named node from within escript and ping some other node like<br>this:<br><br>#!/usr/bin/env escript<br><br>main(_) ->
<br>  net_kernel:start([foo, shortnames]),<br>  erlang:set_cookie(some_random_cookie),<br>  case net_adm:ping(some_other_node) of<br>    pong -> ...<br>    pang -> %% spawn some_other_node<br>      ...<br>  end.<br>
<br>But if epmd isn't running already I get:<br><br>=INFO REPORT==== 19-Sep-2007::18:50:36 ===<br>Protocol: "inet_tcp": register error: {{badmatch,{error,econnrefused}},<br>                                       [{inet_tcp_dist,listen,1},
<br>                                        {net_kernel,start_protos,4},<br>                                        {net_kernel,start_protos,3},<br>                                        {net_kernel,init_node,2},<br>                                        {net_kernel,init,1},
<br>                                        {gen_server,init_it,6},<br>                                        {proc_lib,init_p,5}]}<br>escript: script failed with error reason function_clause<br><br><br><br>Any help appreciated, Steve
<br><br>_______________________________________________<br>erlang-questions mailing list<br><a href="mailto:erlang-questions@erlang.org">erlang-questions@erlang.org</a><br><a href="http://www.erlang.org/mailman/listinfo/erlang-questions">
http://www.erlang.org/mailman/listinfo/erlang-questions</a><br></blockquote></div><br>