Oracle DB user password change

Hi Experts,

I am trying to write a shell script to change DB user password.
Requirement:
login to multiple DBs as multiple users and change their respective passwords.
ex :users:T1,T2,T3
DB:X,Y,Z

scenario:
login as T1 to X,Y,Z
change password

login as T2 to X,Y,Z
change password

login as T3 to X,Y,Z
change password

I have tried something below.
I need to pass old and new password into DB .any idea how to achieve this.?

for LINE in `cat config.data | grep -v "^#"`
do

        DB_NAME=`echo $LINE | cut -f1 -d":"`
        U_NAME=`echo $LINE  | cut -f2 -d":"`
        P_NAME=`echo $LINE  | cut -f3 -d":"`
        
sqlplus -L -S $U_NAME/$P_NAME@$DB_NAME << EOF

alter user acsdba identified by "newpass" replace oldpass; 

EOF

done

exit;

What did the code you posted do? Any errors?

A minor code correction:

while IFS=":" read -r DB_NAME U_NAME P_NAME
do
...
done < config.data

So are you connecting to the database with a privileged account? If not, you can only alter your own password, i.e. that of T1, T2 etc.

If you want to change a privileged account and you can't connect with that account, you might get away with becoming the OS user that owns the database (usually oracle) and doing:-

sqlplus <<-EOSQL
/ as sysdba
alter user acsdba identified by abcdefg ;
EOSQL

Can you clarify the objective a bit? I'm a little confused :confused:

Regards,
Robin