[ejabberd] shell behavior of tty vs stdin

Konstantin Khomoutov flatworm at users.sourceforge.net
Mon Jan 11 20:26:57 MSK 2010


On Mon, 11 Jan 2010 00:32:43 -0800
Brian Acton <acton at whatsapp.com> wrote:

[...]
> ejabberdctl debug < info.erl
> 
> I get a different behavior.
> 
> In the former, i get somewhat expected behaviour as I get the mnesia info.
> However, in the latter, I get basically nothing and the node is identified
> as a debug node. It is as though the remote connection has not been
> instantiated yet.
> 
> Is this normal? I would have expected the two behaviors to be identical.
> Unfortunately, they were not. Lastly, I tried using expect to simulate a tty
> and that failed miserably.
> 
> Can anyone explain?
[...]

I'm not really sure, but seems like you falsely assume the
"Erlang shell" which is started by ejabberdctl debug
behaves like "Unix shell" in that it distinguishes between interactive
and non-interactive modes.

`ejabberdctl debug` start an instance of the Erlang emulator (via the "erl" program) passing it the "-remsh" command-line option and the name of an
Erlang "node" which runs ejabberd. This gives you control over the running
instance of ejabberd, but this is unlike Unix shells, which, when started
non-interactively, read commands from their standard input. Erlang shell
is just a shell.
Also, as far as I know, Erlang is not truly scripted, and to run "script"
it needs a specially instrumented runtime (the escript program, if I recall
correctly) which has certain limitations.

It seems that if you need to execute your own code in ejabberd using
ejabberdctl, the simplest way to go is toook how mod_ctlextra [1]
(mod_admin_extra in versions >= 2.1.0) is implemented and create
a module with your own functions which will plug into ejabberdctl
machinery in the same way.

1. http://www.ejabberd.im/mod_ctlextra


More information about the ejabberd mailing list