Visit Our UNIX and Linux User Community

trouble making a useradd script

Thread Tools Search this Thread
Top Forums Shell Programming and Scripting trouble making a useradd script
# 1  
Old 10-20-2009
trouble making a useradd script

i'm new to scripting in unix and am trying to make a script to add a user and an encrypted password for them. this is what i have and it isn't giving me any errors, but when i try to login with the new user, the password doesn't work. i'm hoping someone can point me in the right direction

echo Enter First and Last name:
read fullname
echo Enter Username:
read username
echo Enter Password:
read password

sudo useradd -c "$fullname" -m -s "/bin/bash" -p `makepasswd --string "$password" --crypt-md5 | awk -F$ '{print "$" $2 "$" $3 "$" $4}'` "$username"

# 2  
Old 10-20-2009
I don't have the command makepasswd on my system, could you please run below command, and paste the output here?

makepasswd --string "testonly" --crypt-md5

And can you use the full path for command useradd, makepasswd and awk in sudo command.

Previous Thread | Next Thread
Test Your Knowledge in Computers #530
Difficulty: Medium
Unicode was supports encoding 1,112,064 possible characters.
True or False?

9 More Discussions You Might Find Interesting

1. UNIX for Beginners Questions & Answers

Help me making this script

This script is executed whenever a new vehicle is added to the cycle-motor park of campus. The script asks for the following information about the car and adds a new line to the vehicle file.txt: name (name of an animal, unique identifier), color, mark, model, type (e.g., electrical, manual),... (2 Replies)
Discussion started by: andre2222
2 Replies

2. Shell Programming and Scripting

Two spaces making trouble

I have really big problems with two spaces. I tried to simplify my problem as much as possible. I have made a script to understand my problem: #!/bin/bash VAR='/path/with/two spaces' echo '/path/with/two spaces' echo $VAR I am a beginner of scripting, but i thought until now i would... (4 Replies)
Discussion started by: matrois
4 Replies

3. Shell Programming and Scripting

Useradd script

Trying to create a bash script that will read the /etc/passwd file for existing UID's before adding a new user and also does an incremental by allocating the next available UID.And also add the user to the correct group.Please help I am a newbie in scripting. (2 Replies)
Discussion started by: tshepang
2 Replies

4. Shell Programming and Scripting

need script for smbldap-useradd/setquota/ldapadd

Hello guys, I am trying to add users to samba/ldap system, set their quota, set them a common password and add auto_home records for the new users User list file is in below format Firstname Lastname Username Command I run to add user is smbldap-useradd -a -m -N $Firstname -S... (0 Replies)
Discussion started by: upengan78
0 Replies

5. Shell Programming and Scripting

Help with useradd script

Ok Im trying too make this shell script create users from my text file, I also want to type in a password for the new users. So thay can make a uniq one themself after first logon. #!/bin/sh # Sebastian schmidt clear echo "*************************************************************"... (3 Replies)
Discussion started by: chipmunken
3 Replies

6. Shell Programming and Scripting

Need help making a script

Here is what I have: #!/bin/bash # Setup year date and month YR=`date +%Y '{print $6}'` MON=`date +%b '{print $2}'` DAY=`date +%d '{print $3}'` file=$YR$MOY$DOM # clear # Dump database using USER/PASS to ..sql mysqldump --user=me -ppass database > database-db.$file.sql The YR, MON and... (2 Replies)
Discussion started by: npereira
2 Replies

7. Shell Programming and Scripting

useradd -c in a script????

Here's my box info: ROOT@fcivra: uname -a SunOS fcivra 5.6 Generic_105181-26 sun4m sparc SUNW,SPARCstation-5 I am creating a script called adduser, that will incorporate the useradd command. Here is what it looks like: #!/bin/sh echo "Enter the person's VZID (lower case): \c" read VZID... (2 Replies)
Discussion started by: cdunavent
2 Replies

8. UNIX for Dummies Questions & Answers

useradd script

I have a txt file with many users and I need to add them and create random passwords. Does any one have a script in pearl possible? (3 Replies)
Discussion started by: macdonto
3 Replies

9. Shell Programming and Scripting

trouble with script

I'm having a little trouble finishing up this script any help would be great. My system is SCO OpenServer Enterprise System (ver 5.0.5m) and i'm using sh This script checks todays date and goes and downloads a file with yesterdays date in the name. ---start---- Server="ipaddresshere"... (4 Replies)
Discussion started by: whegra
4 Replies

Featured Tech Videos