As suggested in the comments, here the revised script
echo -n "Enter user to be created"
read USERNAME
echo -n "Enter new password"
read PASSWORD
output=`sqlplus -s '/nolog' >/dev/null 2>/dev/null <<EOF
WHENEVER SQLERROR EXIT SQL.SQLCODE
connect / as sysdba
CREATE USER "$USERNAME" IDENTIFIED BY "$PASSWORD"
DEFAULT TABLESPACE "$DETAB"
TEMPORARY TABLESPACE TEMP
PROFILE DEFAULT
ACCOUNT UNLOCK;
exit;
EOF`
success=`echo $? `
unset PASSWORD
echo $USERNAME
echo $success
echo $output
echo $PASSWORD
if $success returns 0 everything is ok. if not there is an error.
But $output and $PASSWORD are empty at the end of the execution
For debug purpose, do not redirect to /dev/null but you will see the password.
Passwords are stored encrypted inside Oracle as already said in the comments by other people helping you
Other suggestion
I think that the better solution is to force the User to Change the Password at First/Next Login
e.g Create the user with :
- the option
by a password expire
- a dummy password and
password expire option
- expire the password using the command
alter user $USERNAME password expire;.
By doing this Oracle will ask to the user to update his password at the first or next connection. The password issue will be managed by sqlplus directly (or by other tools).
You can add in your script
conn $USENAME/<dummypwd> and sqlplus will prompt for the new password
identified byclause; Oracle will hash it for its internal storage. (As a one-way hash, not encrypted - you can't get the plain text back from the hashed value, by design.)create userstatement?read -s PASSWORD; the value entered by the user will still be 'unencrypted' but it shouldn't be displayed on the user's terminal