Bash shell script for user creation in solaris

Hi All,

I am new to shell scripting and have a task which need to be completed ASAP.
I have searched all the forum and couln't find excat script which could run on solaris.can someone give me the fully working script for below.

Bash shell script to create user account with paraments as below.

useradd -c "${FNAME} ${LNAME}" -d ${HOMEDIR}/${USERNAME} -m -g ${PRIGROUP} -s ${USERSHELL} ${USERNAME} > /dev/null \
        || exit 1

user should be added to /etc/passwd and I am wondering what could be the command to add password to /etc/shadow, if possible please include that in the script.

If the user already exits then exit from the script otherwise add user.

Thanks in Advance

That command will add them to /etc/shadow, but they will have no password assigned (ie cannot log in). Typically there's no easy way to script password changes as the command is interactive, but you can play round with echo'ing the desired password into "passwd ${USERNAME}" or setting the password manually once on some box, reading it out of the shadow file, then having your script do a sed command to replace "^${USERNAME}:*LK*:" with "${USERNAME}:${ENCRYPTEDPASSWORD}:".