Joe Hortsmann's Jabber User Setup script

Download, Add a comment, Back to main page
[Tue 06:22] thomas (email) the script just stops with "bad interpreter: no such file or directory". I edited hostname, password and the filename of the userlist. What is wrong? System is a Debian Sarge.
[Tue 04:46] Csaba Weisz (email) It seems obvious that this script was developed in Windows environment (C:\perl\perl.exe) so you need to change first line to sthg that reflects correct path to perl on your Debian:

#!/usr/bin/perl

(most probably)
[2004-03-05 05:24 CST] agathis (email) Here (http://agathis.msk.ru/hortsmanns_jus.txt) is script with added support for any language (powered by iconv :)); paths for FreeBSD-4. Also it will remove temp files.
[2004-05-20 17:01 CDT] chris (email) could someone email me the windows version? Thanks
[2004-05-28 18:05 CDT] Dmitrij (email) I'm looking for the windows version too.
[2004-07-30 21:36 CDT] Eric (email) Hi hi, I'm working in a company and running exodus as our instant messaging tool. Is there anyway we can bulk create users? What kind of info do i need to replace if i want to run this script? Thanks alot!


#!/usr/bin/perl

#jus.pl (jabber user setup) version #0.0.2
#Originally based on a script by Joe Horstmann
#date modified: 2003-11-11 by "Giannis Stoilis" <giannis@stoilis.gr>

#I created this script to help create and manage user account setup and roster lists for a corp. intranet server.
#All you have to do is set the initial password for all users and host variables. Then create a userlist.txt file.
#The userlist.txt file should contain the username of each user on a single line.
#Run the jus.pl script in the same dir as the userlist.txt file and the script will create xml files.
#The user xml files will contain a roster with everyone added to everyone's roster.

## stoilis: Added some commands to support Greek rosters, full names, and groups. You need iconv.


#Sets the default password for all users
$password = "password";
#Sets the default jabber server hostname or IP address for all users
$host = "jabber.server.com";
$group = "IT Department";

#Sets the spool path, containing user xml files
$spool_path = "/usr/local/jabber-1.4.2/spool/jabber.server.com";

#Where to read the list from
## ATTENCTION: Format of this file is:
# <username>  <real name>  <group>
## No comments or empty lines allowed. Be sure to seperate every field with 2 spaces
$list_file = "/usr/local/jabber-1.4.2/userlist.txt";


##########
#main routine

&read_list;
&create_roster;
&read_roster;
&create_xml;

exit;

##########
sub read_list {

open INPUT, $list_file;
chomp (@userlist = <INPUT>);
close INPUT;

}

##########
sub create_roster {

open XML,">$spool_path/roster.xml" or die "Cannot open roster.xml for write :$!";

        print XML "<query xmlns='jabber:iq:roster' xdbns='jabber:iq:roster'>";

   foreach $username (@userlist) {
	@user_data = split(/  /,$username);
        print XML "<item jid='$user_data[0]\@$host' name='$user_data[1]' subscription='both'><group>$user_data[2]</group></item>";
   }

        print XML "</query>";

close XML;

}

##########
sub read_roster {

open INPUT, "$spool_path/roster.xml";
chomp ($roster = <INPUT>);
close INPUT;

}

##########
sub create_xml {

   foreach $username (@userlist) {
	@user_data = split(/  /,$username);
       	open XML,">$spool_path/tmp.xml" or die "Cannot open $spool_path/$user_data[0].xml for write :$!";
       	print XML "<xdb><password xmlns='jabber:iq:auth' xdbns='jabber:iq:auth'>$password</password><query xmlns='jabber:iq:register' xdbns='jabber:iq:register'><username>$user_data[0]</username><password xmlns='jabber:iq:auth'>$password</password></query>$roster</xdb>";
       	close XML;
	system "/usr/bin/iconv --from-code=ISO8859-7 --to-code=UNICODE $spool_path/tmp.xml -o $spool_path/$user_data[0].xml";
#	unlink "$spool_path/tmp.xml";
   }

}