在ejabberd上执行push_roster命令时出现'error {badmatch,{error,enoent}}'

时间:2016-04-08 12:05:44

标签: erlang xmpp ejabberd

我正在尝试将批量联系人添加到ejabberd中的用户名单中。我正在使用ejabberd的默认Mnesia数据库。 我创建了一个文件sampleRosterFile。在这个文件中的内容是

[{"kunal", "localhost", "Friend List", "kunal"},{"Rich", "localhost", "Friend List", "Rich"}]

我正在执行命令

sudo ejabberdctl push_roster /home/kunal/Projects/demo/sampleRosterFile kunal localhost

但我收到错误

Problem 'error {badmatch,{error,enoent}}' occurred executing the command.
Stacktrace: [{mod_admin_extra,push_roster,3,
                              [{file,"src/mod_admin_extra.erl"},{line,1145}]},
             {ejabberd_commands,execute_command2,2,
                                [{file,"src/ejabberd_commands.erl"},
                                 {line,410}]},
             {ejabberd_ctl,call_command,3,
                           [{file,"src/ejabberd_ctl.erl"},{line,295}]},
             {ejabberd_ctl,try_call_command,3,
                           [{file,"src/ejabberd_ctl.erl"},{line,271}]},
             {ejabberd_ctl,process2,3,
                           [{file,"src/ejabberd_ctl.erl"},{line,220}]},
             {ejabberd_ctl,process,1,
                           [{file,"src/ejabberd_ctl.erl"},{line,205}]},
             {rpc,'-handle_call_call/6-fun-0-',5,
                  [{file,"rpc.erl"},{line,206}]}]

根据最近的发展情况,我已将我的名册文件设为.txt并再次尝试。但现在这给了我一些与字符串相关的错误

sudo ejabberdctl push_roster /home/kunal/Projects/demo/ejabberd/ebin/sampleRosterFile.txt kunal localhost
Problem 'error function_clause' occurred executing the command.
Stacktrace: [{jid,to_string,[error],[{file,"src/jid.erl"},{line,134}]},
             {mod_admin_extra,build_roster_item,3,
                              [{file,"src/mod_admin_extra.erl"},{line,1200}]},
             {mod_admin_extra,subscribe,8,
                              [{file,"src/mod_admin_extra.erl"},{line,1088}]},
             {mod_admin_extra,subscribe_roster,2,
                              [{file,"src/mod_admin_extra.erl"},{line,1167}]},
             {ejabberd_commands,execute_command2,2,
                                [{file,"src/ejabberd_commands.erl"},
                                 {line,410}]},
             {ejabberd_ctl,call_command,3,
                           [{file,"src/ejabberd_ctl.erl"},{line,295}]},
             {ejabberd_ctl,try_call_command,3,
                           [{file,"src/ejabberd_ctl.erl"},{line,271}]},
             {ejabberd_ctl,process2,3,
                           [{file,"src/ejabberd_ctl.erl"},{line,220}]}]

需要帮助。

2 个答案:

答案 0 :(得分:5)

enoent错误表示无法找到该文件。您可能在命令中犯了错误,无法找到名单文件,或者ejabberd用户无权阅读它。

答案 1 :(得分:2)

早期的代码给了我enoent错误,@MickaëlRémond正确地指出了这一错误 提供名册文件的完整路径会很有帮助。

接下来是error function_clause错误,这意味着没有任何功能或签名与我的输入相匹配

调试后发现mod_admin_extra中push_roster命令的文件格式正确

[{<<"admin">>,<<"localhost">>,<<"Friend">>,<<"Admin">>},{<<"anil">>,<<"localhost">>,<<"Friend">>,<<"Anil">>}]

终于奏效了。

我在博客http://www.techiekunal.in/2016/04/ejabberd-bulk-roster-addition-using-pushroster.html

上找到了有用的解释