ok, my situation is we have a HPUX server and for certain apps each user has to have a certain profile. well i wanna create a useradd script that prompts for the username and password, and it sets the UID to the next available UID and creates the default home directory and everything. Well i have everything fine except the password part. I've looked over the man pages for useradd and i dont see a switch to set the password. so far from what i have is it would create the user for me but after im done runnin the script i would have to set the password for the user manually, i want the script to give the user the password i specify for the script. Heres an example of what im thinking but its not working...

#!/bin/sh
echo Enter Username
read username
echo Enter Password
read password

grep /etc/passd $username
if [ $? -ne 1 ]
then
echo 'Username already in use...'
else
echo "Adding user..."
useradd $username
echo "Making user Home Directory..."
mkdir /home/$username
echo "Creating user Password..."
passwd $password
fi







i get the error that the login ID is invalid or somethin like that (im at home now) and im guessing because it thinks when it executes the passwd command its trying to change the passwd for root or whatever user is running the script. Can anyone help me please. Im lookin for a way to specify what the password should be set with with $password. Someone please. help. Thanks.

keep in mind this is a unix, im gettin mixed results obviously on my linux machine. it works when i take out the grep on my linux machine but ends in error, and it asks me to renter the password at the end of the script, but it works nevertheless. i want it to exit cleanly and not ask me again at the end of the script for the password. i dont have access to a unix machine right now only to my linux one. help is much appreciated. thanks.