command-line-interfaceejabberdejabberd-api

Delete all users from ejabberd server using a script


I am trying to create a script to delete all users from an ejabberd server (for a given Virtual Host).

I have attempted to use e.g. ejabberdctl registered_users example.com to extract the list of users, as per https://www.ejabberd.im/node/4237/index.html

When I run this command however, I get a lot of unwanted output before the users are listed, i.e.:

2023-01-01 18:08:08.865000
    args: ["c:/Windows/System32/drivers/etc/hosts",24]
    format: "inet_parse:~p:~p: erroneous line, SKIPPED~n"
    label: {error_logger,info_msg}
=INFO REPORT==== 1-Jan-2023::18:08:08.865000 ===
inet_parse:"c:/Windows/System32/drivers/etc/hosts":24: erroneous line, SKIPPED

user1
user2
admin

Naturally if I try to use this to execute ejabberdctl unregister for each user, these lines affect the parser. Is there a way to suppress these lines? Alternatively, if there's another way to achieve the deletion of all users (except "admin") via a script or API calls to ejabberd_http that would be just as good.


Solution

  • This turned out to be due to the encoding of the hosts file being UTF-8 instead of ASCII as required by erlang parser. Issue was resolved as per solution provided at:

    https://iammahir.com/2020/12/08/solution-hosts-file-parsing-error-with-erlang-elixir-on-windows/