Scripted change of Oracle password on expiry


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Scripted change of Oracle password on expiry
# 1  
Old 06-16-2011
Scripted change of Oracle password on expiry

Hi All,

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,

Code:
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:


Last edited by pludi; 06-16-2011 at 12:32 PM..
# 2  
Old 06-16-2011
Why don't you just disable the password expiration?
# 3  
Old 06-17-2011
Hi All,

Here is below what I am trying,
Code:
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


Code:
#!/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

Code:
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

# 4  
Old 06-17-2011
It's probably due to timing issues. Change your here doc to
Code:
(
sleep 1
echo $PASS
sleep 1
echo $PASS
) |sqlplus ...

# 5  
Old 06-20-2011
Hi Thanks for revert. I tried but no luck ... still the same error.
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. UNIX for Beginners Questions & Answers

Change - Password expiry Reset (Boot)

I have been searching the web for the answer to this question but without joy. Hopefully, someone here can point me in the right direction... We have a number of application OS accounts which require to be set with password non-expiry via the chage command, such as for example... chage -M 0... (7 Replies)
Discussion started by: ru4n1
7 Replies

2. Shell Programming and Scripting

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 ... (2 Replies)
Discussion started by: navsan420
2 Replies

3. Shell Programming and Scripting

Password Expiry while accessing Oracle table

Hi All, I am not able to access an oracle table even if the table is present. After initial analysis, found that there is a password warning for the specified oracle user. Can you please help me in ignoring the password expiry and access the oracle table ? However, the log file does not store the... (4 Replies)
Discussion started by: tapan8984
4 Replies

4. Shell Programming and Scripting

Password expiry report

Hi All, I want to write a script that will send the alert when linux server password expiry for user 'x' is less than 12 days. I have written the below script but this is not working for expiry date 04 july script;- P_EXPIRY_DATE=`chage -l msdp| grep 'Password expires' | awk ' {... (2 Replies)
Discussion started by: abhigrkist
2 Replies

5. Solaris

disable password expiry

Hi How do i disable password expiration on ldap? It runs on Solaris 10 machine. Thanks in advance. (3 Replies)
Discussion started by: hrist
3 Replies

6. Shell Programming and Scripting

password expiry notification

Hi, Could someone please let me know how to write script for passwd expiry notification on salaries boxes. Regards Dnyan (1 Reply)
Discussion started by: dnyan
1 Replies

7. Solaris

SSH Password-less login fails on password expiry.

Hi Gurus I have a few Sol 5.9 servers and i have enabled password less authentication between them for my user ID. Often i have found that when my password has expired,the login fails. Resetting my password reenables the keys. Do i need to do something to avoid this scenario or is this... (2 Replies)
Discussion started by: Renjesh
2 Replies

8. Solaris

Notification of password expiry.

Hi, Is there any way of sending an email to a number of users indicating that the passwords of user accounts will expire? Currently we have a test server with a number of oracle test accounts on it. Each of these accounts correspond to an instance of Oracle on the server. These... (2 Replies)
Discussion started by: sparcman
2 Replies

9. Solaris

Notification of password expiry.

Hi, Is there any way of sending an email to a number of users indicating that the passwords of user accounts will expire? Currently we have a test server with a number of oracle test accounts on it. Each of these accounts correspond to an instance of Oracle on the server. These... (2 Replies)
Discussion started by: sparcman
2 Replies

10. UNIX for Advanced & Expert Users

password expiry

Hi, under SUN Unix, in which file the expiry date of a user password is indicated ? Many thanks. (2 Replies)
Discussion started by: big123456
2 Replies
Login or Register to Ask a Question