Sponsored Content
Top Forums Shell Programming and Scripting Scripted change of Oracle password on expiry Post 302531613 by gr8_usk on Friday 17th of June 2011 09:38:01 AM
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

 

10 More Discussions You Might Find Interesting

1. 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

2. 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

3. 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

4. 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

5. 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

6. 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

7. 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

8. 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

9. 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

10. 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
OCI_PASSWORD_CHANGE(3)													    OCI_PASSWORD_CHANGE(3)

oci_password_change - Changes password of Oracle's user

SYNOPSIS
bool oci_password_change (resource $connection, string $username, string $old_password, string $new_password) DESCRIPTION
resource oci_password_change (string $dbname, string $username, string $old_password, string $new_password) Changes password for user with $username. The oci_password_change(3) function is most useful for PHP command-line scripts, or when non-persistent connections are used throughout the PHP application. PARAMETERS
o $connection - An Oracle connection identifier, returned by oci_connect(3) or oci_pconnect(3). o $username - The Oracle user name. o $old_password - The old password. o $new_password - The new password to be set. o $dbname - The database name. RETURN VALUES
Returns TRUE on success or FALSE on failure. EXAMPLES
Example #1 oci_password_change(3) example changing the password of an already connected user <?php $dbase = 'localhost/orcl'; $user = 'cj'; $current_pw = 'welcome'; $new_pw = 'geelong'; $c = oci_pconnect($user, $current_pw, $dbase); oci_password_change($c, $user, $current_pw, $new_pw); echo "New password is : " . $new_pw . " "; ?> Example #2 oci_password_change(3) example of connecting and changing the password in one step <?php $dbase = 'localhost/orcl'; $user = 'cj'; $current_pw = 'welcome'; $new_pw = 'geelong'; $c = oci_pconnect($user, $current_pw, $dbase); if (!$c) { $m = oci_error(); if ($m['code'] == 28001) { // "ORA-28001: the password has expired" // Login and reset password at the same time $c = oci_password_change($dbase, $user, $current_pw, $new_pw); if ($c) { echo "New password is : " . $new_pw . " "; } } } if (!$c) { // The original error wasn't 28001, or the password change failed $m = oci_error(); trigger_error('Could not connect to database: '. $m['message'], E_USER_ERROR); } // Use the connection $c ?> NOTES
Note Changing the password either with this function or directly in Oracle should be done carefully. This is because PHP applications may continue to successfully reuse persistent connections by authenticating with the old password. The best practice is to restart all web servers whenever the user password is changed. Note If upgrading the Oracle client libraries or the database from a release prior to 11.2.0.3 to version 11.2.0.3 or higher, oci_pass- word_change(3) may give the error "ORA-1017: invalid username/password" unless both client and server versions are upgraded at the same time. Note The second oci_password_change(3) syntax is available since OCI8 version 1.1. Note In PHP versions before 5.0.0 you must use ocipasswordchange(3) instead. This name still can be used, it was left as alias of oci_password_change(3) for downwards compatability. This, however, is deprecated and not recommended. PHP Documentation Group OCI_PASSWORD_CHANGE(3)
All times are GMT -4. The time now is 07:33 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy