Create Unix User

Is there any way to create user with default password by shell script withoud manual intervantion and from a text file having user's information and default password.

Thanks

It can be done. You need to show us the content of the text file.

Assuming the text file contains something like

name password shell home_directory
john doe /bin/bash /private/john

while read name password shell directory
do
  useradd -d "${directory}" -p "${password} -s "${shell} "${name}"
done < textfile

Hi Vino
Thanks for your reply. but this command is available in Linux only. I am working on unix so need solution for unix.

Thanks again

Good - well done for spotting that Linux isn't actually UNIX

Bad - actually useradd is available for some UNIXs, eg Solaris

Ugly - not giving us a clue what flavour of UNIX you need a solution for

Well putting it in a better way... From the rules

(A) Include as many pertinent details as possible in your post. Useful information usually includes: Vendor and version of hardware or software you are using, hardware platform, kernel version (if applicable).

Thanks to reply the post and sorry for not providing full details

My problem is resolved now using expect. One can have look at it

The link is
http://bash.cyberciti.biz/security/change-password-script.sh.php

Regards & Thanks

Even though this has been solved, it's worth noting that the -p option to specify a password (where available) requires the encrypted password. From "man useradd"

With some versions of the passwd command, you can do things like the following, and pass the unencrypted password on stdin:

# useradd -m -d /home/test test
# echo "newpass" | passwd --stdin test
Changing password for user test.
passwd: all authentication tokens updated successfully.

Cheers
ZB