Operating System - HP-UX
1836534 Members
4789 Online
110102 Solutions
New Discussion

Batch script for useradds

 
SOLVED
Go to solution
Johan Barelds
Frequent Advisor

Batch script for useradds

Hi all!

Is there a simple way to add appr. 1500 users by use of a script? I found out that using the passwd command is not usable in a script because it keeps prompting. Are the ways to deal with this?

Thanks for any reply!
Grz. Johan
Make my day..:-)
7 REPLIES 7
Steven E. Protter
Exalted Contributor

Re: Batch script for useradds

This thread contains a script that does that.

I've got one at work, but I'm not there so this will have to suffice.

http://forums.itrc.hp.com/cm/QuestionAnswer/1,,0x72bcd06ed8c8d4118fef0090279cd0f9,00.html

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
Johan Barelds
Frequent Advisor

Re: Batch script for useradds

Thanks Steven,

But in the threat i miss the most important problem: setting a password via the script in bulk mode. Do you have the in your script at the office?

Grz. Johan
Make my day..:-)
Bill Hassell
Honored Contributor
Solution

Re: Batch script for useradds

The process to add a password is very different between a Trusted system and standard HP-UX. I've attached a simple C program that compiles with the built-in HP-UX compiler. It will accept a standard (8-char max) password and returns the 13 character encrypted password string. For a non-trusted system, you would insert the string after the first colon in the passwd entry. For a Trusted system, you will have to add the entry to the appropriate /tcb database file.


Bill Hassell, sysadmin
John Meissner
Esteemed Contributor

Re: Batch script for useradds

Here is a script I wrote. It will not generate automatic UID's becuase we have a specific UID that each individual will get.
All paths lead to destiny
John Meissner
Esteemed Contributor

Re: Batch script for useradds

Here is a script I wrote. It will not generate automatic UID's becuase we have a specific UID that each individual will get.
All paths lead to destiny
Chris Wilshaw
Honored Contributor

Re: Batch script for useradds

If you're using HP-UX 11, you can use

passwd -d -f

This deletes the current password (in the case of the new ID, this will be the * for a locked account), and forces the user to select a new password when they next log in.

If you want to add password expiry, you can use

passwd -d -f -x 28

which will do the above, and will also make the user change their password every 28 days (28 is only used as an example - this can be extended to whatever your security policy dictates).
Johan Barelds
Frequent Advisor

Re: Batch script for useradds

Thanks all!

Especially Bill and Chris: that where the solutions i was looking for!

Grz. johan
Make my day..:-)