diff --git a/THANKS b/THANKS index 3db3b4c..9b9a448 100644 --- a/THANKS +++ b/THANKS @@ -127,3 +127,4 @@ alisdair sullivan Alexander Verbitsky Andras Horvath Drew Varner +Roberto Aloi \ No newline at end of file diff --git a/priv/templates/simplenode.nodetool b/priv/templates/simplenode.nodetool index ce06c6a..7ae8a27 100755 --- a/priv/templates/simplenode.nodetool +++ b/priv/templates/simplenode.nodetool @@ -95,9 +95,23 @@ main(Args) -> Other -> io:format("~p\n", [Other]) end; + ["eval", Str0] -> + Str = string:strip(Str0, right, $.) ++ ".", + Bindings = erl_eval:new_bindings(), + case rpc:call(TargetNode, + erl_eval, + exprs, + [parse(Str), Bindings], + 60000) of + {badrpc, Reason} -> + io:format("RPC to ~p failed: ~p\n", [TargetNode, Reason]), + halt(1); + {value, Value, _Bindings} -> + io:format("~p\n", [Value]) + end; Other -> io:format("Other: ~p\n", [Other]), - io:format("Usage: nodetool {chkconfig|getpid|ping|stop|restart|reboot|rpc|rpc_infinity|rpcterms}\n") + io:format("Usage: nodetool {chkconfig|getpid|ping|stop|restart|reboot|rpc|rpc_infinity|rpcterms|eval}\n") end, net_kernel:stop(). @@ -180,3 +194,8 @@ consult(Cont, Str, Acc) -> {more, Cont1} -> consult(Cont1, eof, Acc) end. + +parse(Str) -> + {ok, Tokens, _} = erl_scan:string(Str), + {ok, Exprs} = erl_parse:parse_exprs(Tokens), + Exprs. diff --git a/priv/templates/simplenode.runner b/priv/templates/simplenode.runner index 3e9e10f..b33d475 100755 --- a/priv/templates/simplenode.runner +++ b/priv/templates/simplenode.runner @@ -293,6 +293,19 @@ case "$1" in exec $ERTS_PATH/to_erl $PIPE_DIR ;; + eval) + # Make sure a node IS running + ping_node > /dev/null 2>&1 + ES=$? + if [ "$ES" -ne 0 ]; then + echo "Node is not running!" + exit $ES + fi + + shift + $NODETOOL eval "$1" + ;; + remote_console) # Make sure a node is running ping_node @@ -396,7 +409,7 @@ case "$1" in echo $PID ;; *) - echo "Usage: $SCRIPT {start|start_boot |foreground|stop|restart|reboot|ping|console|getpid|console_clean|console_boot |attach|remote_console|upgrade}" + echo "Usage: $SCRIPT {start|start_boot |foreground|stop|restart|reboot|ping|console|getpid|console_clean|console_boot |attach|eval|remote_console|upgrade}" exit 1 ;; esac diff --git a/test/upgrade_project/rel/files/dummy b/test/upgrade_project/rel/files/dummy index c2ef258..d20c86e 100755 --- a/test/upgrade_project/rel/files/dummy +++ b/test/upgrade_project/rel/files/dummy @@ -234,6 +234,19 @@ case "$1" in exec $ERTS_PATH/to_erl $PIPE_DIR ;; + eval) + # Make sure a node IS running + ping_node > /dev/null 2>&1 + ES=$? + if [ "$ES" -ne 0 ]; then + echo "Node is not running!" + exit $ES + fi + + shift + $NODETOOL eval "$1" + ;; + remote_console) # Make sure a node is running ping_node @@ -339,7 +352,7 @@ case "$1" in echo $PID ;; *) - echo "Usage: $SCRIPT {start|start_boot |foreground|stop|restart|reboot|ping|console|getpid|console_clean|console_boot |attach|remote_console|upgrade}" + echo "Usage: $SCRIPT {start|start_boot |foreground|stop|restart|reboot|ping|console|getpid|console_clean|console_boot |attach|eval|remote_console|upgrade}" exit 1 ;; esac diff --git a/test/upgrade_project/rel/files/nodetool b/test/upgrade_project/rel/files/nodetool index ce06c6a..7ae8a27 100644 --- a/test/upgrade_project/rel/files/nodetool +++ b/test/upgrade_project/rel/files/nodetool @@ -95,9 +95,23 @@ main(Args) -> Other -> io:format("~p\n", [Other]) end; + ["eval", Str0] -> + Str = string:strip(Str0, right, $.) ++ ".", + Bindings = erl_eval:new_bindings(), + case rpc:call(TargetNode, + erl_eval, + exprs, + [parse(Str), Bindings], + 60000) of + {badrpc, Reason} -> + io:format("RPC to ~p failed: ~p\n", [TargetNode, Reason]), + halt(1); + {value, Value, _Bindings} -> + io:format("~p\n", [Value]) + end; Other -> io:format("Other: ~p\n", [Other]), - io:format("Usage: nodetool {chkconfig|getpid|ping|stop|restart|reboot|rpc|rpc_infinity|rpcterms}\n") + io:format("Usage: nodetool {chkconfig|getpid|ping|stop|restart|reboot|rpc|rpc_infinity|rpcterms|eval}\n") end, net_kernel:stop(). @@ -180,3 +194,8 @@ consult(Cont, Str, Acc) -> {more, Cont1} -> consult(Cont1, eof, Acc) end. + +parse(Str) -> + {ok, Tokens, _} = erl_scan:string(Str), + {ok, Exprs} = erl_parse:parse_exprs(Tokens), + Exprs.