LinuxQuestions.org
Go Job Hunting at the LQ Job Marketplace
Go Back   LinuxQuestions.org > Forums > Non-*NIX Forums > Programming
User Name
Password
Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.

Notices

Reply
 
Search this Thread
Old 06-18-2004, 08:19 AM   #1
plexus
LQ Newbie
 
Registered: Feb 2004
Location: Singapore
Distribution: Windows XP, RedHat 9
Posts: 16

Rep: Reputation: 0
Adding multiple user shell script


Hi all

Does anyone know how do I write (or is it already available) a shell script in redhat 9 that add 100 user account in a sequential manner?

EG: user1, user2 ....

Also, is it possible to specify a default password and perhaps, even add the generated users to a specific group?

Thanks
 
Old 06-18-2004, 03:01 PM   #2
kshim5
LQ Newbie
 
Registered: Oct 2003
Distribution: RedHat
Posts: 6

Rep: Reputation: 0
Adding a user script read carefully

Found this on the web it may be able to help



#! /bin/sh
#
# This is a script for adding users to the system,
# that also will mail them a welcome message.
# by Luke Th. Bullock (lucc@anart.no) AUG 03, 1997
#
# Check user (from addluser by Scott Womer <womer@ntlug.org>)
if [ `id -u` != 0 ]; then
echo "Sorry, only root can add users to this system."
exit 1
fi
#
# Set the system envar
SYS="/usr/sbin"
#
# Print the Help message
#
if [ "$1" = -h ]; then
cat << EOF

Newuser Script v0.2 (03AUG1997)
by Luke Th. Bullock (lucc@anart.no)

This script requires the files "adduser" and "mail".
To add a new user, specify the login name at the prompt:
"newuser harry" (without the quotes).
Then fill in the questionaire with the appropriate data
for the new user. This script will also, after adding the
new account, send a Welcome Message to the new user, and
add the user to the file /root/accounts for log purposes.

EOF

unset SYS
exit
fi
#
# Search for adduser
#
if [ -f ${SYS}/adduser ]; then
ADD=${SYS}/adduser
else
echo "Cannot find required file \"adduser\" in $SYS."
echo "Please type \"newuser help\" for more info."
unset SYS
exit
fi
# All is well, add the user and send the welcome mail.
#
if [ "$1" ]; then
$ADD
# Send the email to the user
#
cat << EOF |mail -s 'Welcome New User' $1

Welcome New User

If you have any questions, send an email to root,
or to support. If you wish to make a home page,
make the directory public_html/, chmod it 755,
then cd public_html, create the file index.html
and chmod it 644. Now you are set, create your pages.
Ask root or support for your disc quota, normally
it should be 5MB.

System Admin

EOF
#
# Keep a log of new users
echo $1 >> /root/accounts
#
# Sleep for 3 secs while the system does it's stuff..
sleep 3
# Finger the user to see all is correct
finger $1
#
else # If no arg is used, print a short explanation
echo "usage: newuser \"user\" (type "newuser -h" for help)"
unset SYS
fi
#
#End of Script
 
Old 06-19-2004, 08:36 PM   #3
plexus
LQ Newbie
 
Registered: Feb 2004
Location: Singapore
Distribution: Windows XP, RedHat 9
Posts: 16

Original Poster
Rep: Reputation: 0
It works fine for me, with a little modification.

Thanks
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Adding new users via Shell script coolfrog Linux - General 10 12-05-2010 10:47 AM
Shell script adding autostart gnome script Coolrunr Programming 3 01-01-2009 02:23 PM
Adding a shell script to startup Dakkar Suse/Novell 3 10-15-2005 08:00 AM
bash script for adding multiple users pilipk01 Linux - Newbie 4 01-12-2004 10:05 PM
adding a job to crontab via shell script tazio Linux - General 7 10-23-2003 02:44 PM


All times are GMT -5. The time now is 10:22 PM.

Main Menu
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
identi.ca: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration