Simple sh called by PHP to create users HELP

Hello! Im trying to create a shell script that will be executed by PHP like:

$return = shell_exec("./makeUser.sh $user $pass");

My shell script looks like:

#!/bin/bash

NAME=$1
PWD=$2

pass=$(perl -e 'print crypt($ARGV[0], "password")' $PWD)
useradd -m -p $pass $NAME
[ $? -eq 0 ] && echo "0" || echo "1"

The problem I having is that the user is getting created but the password is not getting set. How can I solve this issue?

Thanks

I'm astonished that it even creates the user. How is this script being run? Your httpd should not have root access.

I guess I forgot the sudo part on the shell_exec() and I have to enter my pass when I run this. As bad as it is the company setup http to have sudo access (im told). There is a python script that does this but there is some issues with it and no one at the office knows python or shell scripting. In short this is my poor attempt to port that code into PHP (Im also a n00b on shell scripting).