ejabberdctl register problem from .rb script

so i'm running this adduser.rb file to register users and it's not working for some reason. It works fine from the command line, but kicks me back a 256 error from the browser and tell me that the user already exists when it doesn't.

HELP!

#!/usr/bin/env ruby

require 'cgi'

cgi = CGI.new('html4')

username = cgi['username']
passwd = cgi['passwd']
result = 0

# Add User to Jabber Server
ENV['HOME'] = '/home/kit'
system('sudo /opt/ejabberd-1.1.1/bin/ejabberdctl register ' + username + ' talk.macgames-network.com ' + passwd + ' > /dev/null')
result = $?.to_i

# Result codes
# 0     All is cool
# 256   User already exists in server
# 512   Invalid user parameters

rstatus = 500
rmessage = 'Unknown error.'

case result
when 0
        rstatus = 201
        rmessage = 'Account created.'
when 256
        rmessage = 'User already exists.'
when 512
        rmessage = 'Invalid values in parameters.'
end

cgi.out('status' => rstatus.to_s) {
        rmessage
}

Maybe this patch that prints

Maybe this patch that prints the arguments will help you to debug the problem:

--- ejabberd_ctl.erl	(revisión: 751)
+++ ejabberd_ctl.erl	(copia de trabajo)
@@ -70,6 +70,7 @@
     ?STATUS_SUCCESS;
 
 process(["register", User, Server, Password]) ->
+	io:format("register this: ~p, ~p, ~p.~n", [User, Server, Password]),
     case ejabberd_auth:try_register(User, Server, Password) of
 	{atomic, ok} ->
 	    ?STATUS_SUCCESS;
@@ -209,6 +210,7 @@
 process(Args) ->
     case ejabberd_hooks:run_fold(ejabberd_ctl_process, false, [Args]) of
 	false ->
+		io:format("Not processed: ~p.~n", [Args]),
 	    print_usage(),
 	    ?STATUS_USAGE;
 	Status ->
Syndicate content