Operating System - Linux
1752618 Members
4276 Online
108788 Solutions
New Discussion

help to make a good script to create users

 
uadm26
Super Advisor

help to make a good script to create users

Hi,
I need to create a solution, to create a range user in a different HP-UX system 11.23.
The best idea is use one system to run a script that creates users in all others systems, with same userid, to make shore that all passwd are equal.
I have some knowledge of shell script, but I’ll like to create an interface for my script too.
I need your opinions. Thanks.
10 REPLIES 10
Steven E. Protter
Exalted Contributor

Re: help to make a good script to create users

I have a series of scripts that include a library and interface for creating users. I believe I have all of the components on an HP-UX xerver behind me.

The interface needs to build the useradd command to meet your needs. Is that what you are looking for?

SEP
Steven E Protter
Owner of ISN Corporation
http://isnamerica.com
http://hpuxconsulting.com
Sponsor: http://hpux.ws
Twitter: http://twitter.com/hpuxlinux
Founder http://newdatacloud.com
uadm26
Super Advisor

Re: help to make a good script to create users

Hi,
I have a script to run in a single system, with a simple interface using echo command. I'm trying to create a new one, with functions, more elaborated, with an interface that I can navigate, for example, with Tab key.
uadm26
Super Advisor

Re: help to make a good script to create users

If someone have scripts with some of that things would help me.
Ranjith_5
Honored Contributor

Re: help to make a good script to create users

Create a file called user.dat on the same directory of the create_users script.

Data format of user.dat would be

employee_code First_Name Last_name

#########################################################################
#create_user script.
#Created by Syam
#########################################################################
#!/usr/bin/sh
#
groupadd dbuser
rm -f passwords.dat
#read all the data in the file user.dat
while read data
do
#split the fields up
#first field
logid=`echo $data | cut -d' ' -f1`
#second field onwards
username=`echo $data | cut -d' ' -f2-`
useradd -c "$username" -g dbuser -m -s /usr/bin/ksh -k /etc/skel -d /home/db$logid db$logid
/usr/lbin/modprpw -x db$logid >> passwords.dat
echo "Created user $username"
done < user.dat
cat passwords.dat|cut -f2 -d"=">passwords.txt
rm -f passwords.dat
#


Regards,
Syam
Ranjith_5
Honored Contributor

Re: help to make a good script to create users

The above script is for a trusted system.

Regards,
Syam
uadm26
Super Advisor

Re: help to make a good script to create users

Hi,
Well what I really need is something more elaborated how to build an interface.
And then the best code to use for create that script. My script itâ s in attachment.
Tim Nelson
Honored Contributor

Re: help to make a good script to create users

The script I have created and used is like Syam's.

korn shell with use of master.pass file on one system.

after entering name, it checks for existance and shows entry. Select if you like or choose different name. The uids are segregated. daemon uid is 100-199, normal users are 200-499, other could be 500-699, etc each with different settings for password expire etc.



Once completed the script creates a file called /tmp/new. The contents are the commands of useradd, modprpwx, etc, all the commands you would manually use. Then as this script is run as non-root user, it rcp it to either a selected system or all systems.
Then login to each system as root and run the new file with the commands.

Florian Heigl (new acc)
Honored Contributor

Re: help to make a good script to create users

If You want to have real menus and such, You should look into either (n)curses or tcl/tk.

a friend of mine also wrote a small widget library in ksh, I've asked him for a link, as I don't remember where to find it at the moment.

florian
yesterday I stood at the edge. Today I'm one step ahead.
Florian Heigl (new acc)
Honored Contributor

Re: help to make a good script to create users

Here is the link to the library:

http://cvs.laladev.org/index.html/laladev/lalaKSHWidgets/

I think it can do what You need.
yesterday I stood at the edge. Today I'm one step ahead.