[英]How start ejabberdctl from bash script properly?
I need to register many thousands of users in ejabberd from csv file.我需要从 csv 文件在 ejabberd 中注册成千上万的用户。 For this, I wrote a simple script.
为此,我编写了一个简单的脚本。
#!/bin/sh
OLDIFS=$IFS
IFS=','
[ ! -f $INPUT ] && { echo "$INPUT file not found"; exit 99; }
while read username domain pass p1 p2 p3 p4
do
echo "ejabberdctl register $username $domain $pass"
ejabberdctl register $username $domain $pass
done < users.csv
IFS=$OLDIFS
But in the end, the answer is: Error: cannot_register If I just run the line copied from the output, everything is ok.但最后,答案是:错误:cannot_register 如果我只是运行从 output 复制的行,一切正常。 The user is created normally.
用户是正常创建的。
This is just a little trick for later: once you get your loop working, if you consider ejabberdctl is too slow, you can try using the ReST API.这只是以后的一个小技巧:一旦你的循环工作,如果你认为ejabberdctl太慢,你可以尝试使用 ReST API。 That should be a lot faster when doing many requests.
执行许多请求时,这应该快得多。
Configure temporarily something like this (remember to remove this when you finished):临时配置类似这样的东西(记得在完成后删除它):
listen:
-
port: 5280
module: ejabberd_http
tls: false
request_handlers:
/api: mod_http_api
api_permissions:
"console commands":
from:
- ejabberd_ctl
- mod_http_api
who: all
what: "*"
modules:
mod_http_api: {}
Then execute this in a shell to register an account:然后在 shell 中执行此操作以注册帐户:
curl 'localhost:5280/api/register?user=user2&host=localhost&password=somepass123'
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.