Koozali.org: home of the SME Server

abl-batch_users-0.5

jane

abl-batch_users-0.5
« on: April 07, 2003, 11:20:26 AM »
Hi all,

I've question regarding on users creation via batch files. I've use batch script created by Abe Loveless.

The script let the creation of users with the following format successfully.
USERNAME:PASSWORD:FIRSTNAME:LASTNAME:GROUPNAME

My question is how do I modify the script if I want to add more fields eg. dept, company,street n etc.

Hope the author of the script can give some ideas.

Thanks in advance!

Abe Loveless

Re: abl-batch_users-0.5
« Reply #1 on: April 07, 2003, 07:53:29 PM »
Hi Jane,

Actually there are a couple of places that you will need to edit.

In "script.pl", you'll need to update it to handle more variables.  So, around line 21, you'll see 2 lines that run for each field in the array.   Something like this:

   $input_split[0] =~ s/^\s+//;
   $input_split[0] =~ s/\s+$//;

This processes the variable to take out in empty spaces and newline characters, if I remember correctly.  Just add these 2 lines, and increment the number for each additional variable that you wish to add.

In line 42, you'll need to add the new variables in the system call that calls the "adduser" script.  The format of the line should look like this:
   acctName, Passwd, firstName, lastName, department, company, street, city, phone

So, if you don't want to use one of those fields, you'll need to put blank quotes ("") as a place holder for each field that you don't want. (Unless, the blank fields fall at the end of the list.)

Save the file, you're done with it.  Now you need to edit the "adduser" script, which is located in the same directory.

In line 92, the "$x" (where x is a number) represent your variables.  You'll see a number of $x, and several blank quotes.  Depending on which location above, your new field falls in, you'll need to add the appropriate variable number.  So, if you wanted to add street, city, and phone, you would have to change the entries for $7, $8, and $9.

That should be about it.  Hope that makes a little bit of sense.

If not, let me know and specify which fields you want to add and I'll see about making the changes for you.