Koozali.org: home of the SME Server

Adding Multiple Users

Karl McElwain

Adding Multiple Users
« on: June 17, 2002, 07:08:33 PM »
Okay I've made the script and the import file....I'm in the correct folder /root

I've logged in as root....and verified the files are there.  But I'm getting an error when I try to run it

bash:  e-smith-add-user.sh: command not found

anybody have any ideas?

Thanks

Kees Vonk

Re: Adding Multiple Users
« Reply #1 on: June 17, 2002, 07:39:10 PM »
Try

./e-smith-add-user.sh

Kees

Karl McElwain

Re: Adding Multiple Users
« Reply #2 on: June 17, 2002, 07:47:11 PM »
well that did something....now I'm getting permission denied....I'm logged on as root so I really don't understand what could be going on.

Kees Vonk

Re: Adding Multiple Users
« Reply #3 on: June 17, 2002, 07:51:40 PM »
Has you script got execute permissions?

Kees

Karl McElwain

Re: Adding Multiple Users
« Reply #4 on: June 17, 2002, 07:55:53 PM »
I actually just thought about that and it wasn't set to be executable....what about the text file....what sort of permissions should it have?

Thanks I'm getting there.

Kees Vonk

Re: Adding Multiple Users
« Reply #5 on: June 17, 2002, 08:00:52 PM »
As I don't know the script you are running I am not sure, but I presume that 644 with root:root ownership would do as you are running the script under root.

Kees

Karl McElwain

Re: Adding Multiple Users
« Reply #6 on: June 17, 2002, 08:08:51 PM »
Success....I finally got it to run....i got the permissions all set and it started running the script.

Now the only problem is that the script is giving me errors....any idea on where I can get a clean script that works?

Oh by the way thank you soooo much.....I should have looked at the exec option but sometimes it takes somebody else to point out the obvious.

Karl

Kees Vonk

Re: Adding Multiple Users
« Reply #7 on: June 17, 2002, 08:22:22 PM »
I might be able to help you if you can explain where you got the script from and what it is suppost to do.

Kees

Karl McElwain

Re: Adding Multiple Users
« Reply #8 on: June 17, 2002, 08:23:07 PM »
here's what I got....line 31 something wrong with the "do" statement....already fixed the "fi" on line 23...changed it to "if"
---------------------
#!/bin/sh
#
# USAGE:
#
# Create the file /root/adduserlist.txt in the following format:
#
# USERNAME1:FIRSTNAME1:LASTNAME1
# USERNAME2:FIRSTNAME2:LASTNAME2
#
# and so on...
#
# This script will create user accounts, mail accounts and pseudonyms for all the listed users in the /root/adduserlist.txt file.
#
# NOTE *By default usernames/passwords are set to the same value*
#

UFILE=/root/adduserlist.txt

if [ ! -f $UFILE ]; then
echo User database $UFILE missing
exit
if

# export record=cat $UFILE
# if [ "$record" != "" ]; then

# --------------------------
# Make sure the lines below are all indented as shown
# --------------------------
   for record in cat $UFILE
   do
   username=echo $record | awk -F":" {'print $1'}
   firstname=echo $record | awk -F":" {'print $2'}
   lastname=echo $record | awk -F":" {'print $3'}
   uid=echo $record | awk -F":" {'print $4'}
   number=$RANDOM

# ----------------------
# Set values for account
# ----------------------
#
# Available values and options are shown below as 'option' :
#
# FirstName $firstname
# LastName $lastname
# Dept 'department'
# Company 'company name'
# Street 'address'
# City 'city, postal, prov/state, country'
# Phone 'phone number'
# EmailForward 'local, forward, both'
# ForwardAddress 'leave blank or enter forward address'
#
# Below are the minimum values with no changes required
#
/sbin/e-smith/db accounts set $username user FirstName $firstname LastName $lastname PasswordSet no Uid $number Gid $number

# ---------------
# Create Account
# ---------------
/sbin/e-smith/signal-event user-create $username

# ---------------
# Pause Script, bug reported by Jeffrey Smith
# ---------------
sleep 3

# ----------------
# Create Password
# -----------------------------------------------------
# (in this case the username and password are the same)
# eg: ( '$username', 'PASSWORD' );"
# -----------------------------------------------------
perl -e "use esmith::util; esmith::util::setUserPassword ( '$username', '$username' );"

# ---------------------------------
# Set value for password as created
# ---------------------------------
/sbin/e-smith/db accounts setprop $username PasswordSet yes

# ---------------------------------------------------------
# Create Pseudonym (FIRSTNAME.LASTNAME@domain.org)
# Create Pseudonym (FIRSTNAME_LASTNAME@domain.org)
# (simple comment these lines out to not create Pseudonyms)
# ---------------------------------------------------------
/sbin/e-smith/signal-event pseudonym-create $firstname.$lastname $username
/sbin/e-smith/signal-event pseudonym-create $firstname_$lastname $username

done

Rich Lafferty

Re: Adding Multiple Users
« Reply #9 on: June 17, 2002, 08:29:04 PM »
Karl McElwain wrote:
>
> here's what I got....line 31 something wrong with the "do"
> statement....already fixed the "fi" on line 23...changed it
> to "if"

That's not fixed. 'fi' closes 'if'.

  -Rich

robert

Re: Adding Multiple Users
« Reply #10 on: June 17, 2002, 08:31:03 PM »
Actually, fi closes an if statement.

robert

Re: Adding Multiple Users
« Reply #11 on: June 17, 2002, 08:31:53 PM »
You beat me, Rich.

Karl McElwain

Re: Adding Multiple Users
« Reply #12 on: June 17, 2002, 08:36:41 PM »
okay then.....do either of you know why I'm getting a syntax error when it's "fi"

and the "do"?

Karl McElwain

Re: Adding Multiple Users
« Reply #13 on: June 17, 2002, 08:45:40 PM »
hey guess what...I believe I figured it out.   When I used MC to edit the file is appears that there was some sort of character at the end of the line.  Once I did that it worked.  Thanks for everyone's help.