I want to write a shell script to change the password on list of database servers, please guide me how do I achieve this.
Please see below sample, how it is asking while manually changing the password,
sqlplus test@oracle
SQL*Plus: Release 9.2.0.2.0 - Production on Thu Jun 16 10:44:02 2011
Copyright (c) 1982, 2002, Oracle Corporation. All rights reserved.
Enter password:
ERROR:
ORA-28001: the password has expired
Changing password for test
New password:
Code:
#!/bin/shset -xORACLE_HOME="/optware/oracle/9.2.0.2_64"SQLPLUS="${ORACLE_HOME}/bin/sqlplus"PASS="xyz"PATH=$ORACLE_HOME/bin:$PATHLD_LIBRARY_PATH=$ORACLE_HOME/lib:$ORACLE_HOME/lib32:$LD_LIBRARY_PATHexport ORACLE_HOME PATH LD_LIBRARY_PATH ENVfor HOST in `cat ora_srv_list.txt`do$SQLPLUS -S -L user/abc@${HOST} << EOD_ORA $PASS $PASS exit EOD_ORA done
Below is the output which I am getting,
Code:
ORACLE_HOME=/optware/oracle/9.2.0.2_64SQLPLUS=/optware/oracle/9.2.0.2_64/bin/sqlplusPASS=xyzPATH=/optware/oracle/9.2.0.2_64/bin:+ export ORACLE_HOME PATH LD_LIBRARY_PATH ENV cat ora_srv_list.txt + /optware/oracle/9.2.0.2_64/bin/sqlplus -S -L user/abc@oradb catxyzxyzquitERROR:ORA-28001: the password has expiredChanging password for userSP2-0650: New passwords do not matchPassword unchangedSP2-0751: Unable to connect to Oracle. Exiting SQL*Plus
Seems this is getting messed up up because it is asking twice to enter password.
Pelase advice how do I fix this.
Regards,
Uday
#!/bin/sh
set -x
ORACLE_HOME="/optware/oracle/9.2.0.2_64"
SQLPLUS="${ORACLE_HOME}/bin/sqlplus"
PASS="xyz"
PATH=$ORACLE_HOME/bin:$PATH
LD_LIBRARY_PATH=$ORACLE_HOME/lib:$ORACLE_HOME/lib32:$LD_LIBRARY_PATH
export ORACLE_HOME PATH LD_LIBRARY_PATH ENV
for HOST in `cat ora_srv_list.txt`
do
$SQLPLUS -S -L user/abc@${HOST} << EOD_ORA
$PASS
$PASS
exit
EOD_ORA
done
ORACLE_HOME=/optware/oracle/9.2.0.2_64
SQLPLUS=/optware/oracle/9.2.0.2_64/bin/sqlplus
PASS=xyz
PATH=/optware/oracle/9.2.0.2_64/bin:
+ export ORACLE_HOME PATH LD_LIBRARY_PATH ENV cat ora_srv_list.txt
+ /optware/oracle/9.2.0.2_64/bin/sqlplus -S -L user/abc@oradb cat
xyz
xyz
quit
ERROR:
ORA-28001: the password has expired
Changing password for user
SP2-0650: New passwords do not match
Password unchanged
SP2-0751: Unable to connect to Oracle. Exiting SQL*Plus