diff options
| -rw-r--r-- | docs/rabbitmqctl.1.xml | 16 | ||||
| -rw-r--r-- | src/rabbit_control.erl | 7 |
2 files changed, 23 insertions, 0 deletions
diff --git a/docs/rabbitmqctl.1.xml b/docs/rabbitmqctl.1.xml index f21888bd70..157550387d 100644 --- a/docs/rabbitmqctl.1.xml +++ b/docs/rabbitmqctl.1.xml @@ -1315,6 +1315,22 @@ </para> </listitem> </varlistentry> + + <varlistentry> + <term><cmdsynopsis><command>eval</command> <arg choice="req"><replaceable>expr</replaceable></arg></cmdsynopsis></term> + <listitem> + <para> + Evaluate an arbitrary Erlang expression. + </para> + <para role="example-prefix"> + For example: + </para> + <screen role="example">rabbitmqctl eval 'node().'</screen> + <para role="example"> + This command returns the name of the node to which rabbitmqctl has connected. + </para> + </listitem> + </varlistentry> </variablelist> </refsect2> diff --git a/src/rabbit_control.erl b/src/rabbit_control.erl index fa8dd262e1..9d47a78f16 100644 --- a/src/rabbit_control.erl +++ b/src/rabbit_control.erl @@ -368,6 +368,13 @@ action(report, Node, _Args, _Opts, Inform) -> [print_report(Node, Q) || Q <- ?GLOBAL_QUERIES], [print_report(Node, Q, [V]) || Q <- ?VHOST_QUERIES, V <- VHosts], io:format("End of server status report~n"), + ok; + +action(eval, Node, [Expr], _Opts, _Inform) -> + {ok, Scanned, _} = erl_scan:string(Expr), + {ok, Parsed} = erl_parse:parse_exprs(Scanned), + {value, Value, _Bindings} = rpc_call(Node, erl_eval, exprs, [Parsed, []]), + io:format("~p~n", [Value]), ok. %%---------------------------------------------------------------------------- |
