Help required to write shell script to change passwd


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Help required to write shell script to change passwd
# 1  
Old 06-17-2011
Help required to write shell script to change passwd

Hi All,

I wanted to write a shell script which will change the expired passwd in oracle. Here is below what I am trying,

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

Below is the output which I am getting,

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

Seems this is getting messed up up because it is asking twice to enter password.

Pelase advice how do I fix this.

Regards,
Uday

Moderator's Comments:
Mod Comment Double post, continued here

Last edited by pludi; 06-17-2011 at 10:04 AM..
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Ssh passwd less, shell script

Hi All, Wishes!! I need some help to prepare a script to copy the public key from admin host to multiple client hosts to make them login without password. Detailed : I have an admin host "admin1" and i generated sshkeygen, now i have id_rsa.pub and i have around 50 client hosts. i... (4 Replies)
Discussion started by: kumar85shiv
4 Replies

2. Shell Programming and Scripting

How to write config shell script to pass variables in master shell script?

Dear Unix gurus, We have a config shell script file which has 30 variables which needs to be passed to master unix shell script that invokes oracle database sessions. So those 30 variables need to go through the database sessions (They are inputs) via a shell script. one of the variable name... (1 Reply)
Discussion started by: dba1981
1 Replies

3. UNIX for Dummies Questions & Answers

How to write Config shell script to pass variables in master shell script?

Dear Unix gurus, We have a config shell script file which has 30 variables which needs to be passed to master unix shell script that invokes oracle database sessions. So those 30 variables need to go through the database sessions (They are inputs) via a shell script. one of the variable name... (1 Reply)
Discussion started by: dba1981
1 Replies

4. HP-UX

Sudo entry required to set permission similar to ROOT without using password (PASSWD) change optio

Hi All I had installed sudo in HP UX 11.3 and it is working fine but not able to make entry required to set permission similar to ROOT without using password (PASSWD) change option for define user in /etc/sudoers file Please help if some know the syntex? :confused::wall: (2 Replies)
Discussion started by: deviltech
2 Replies

5. Shell Programming and Scripting

Need script to monitor change in /etc/passwd

Hi All, From Audit point of view, I need to add a script to my production Solaris servers. That should be able to mail me, if any user is added or removed. That means, I should get a mail, what user is deleted or added in /etc/passwd, i.e. if there is a change in this file, I should be... (8 Replies)
Discussion started by: solaris_1977
8 Replies

6. Shell Programming and Scripting

how to write script to change email address

we have 4000 html pages that need an email address changed. eg) company@yahoo.com to company@hotmail.com we only want the file modified date to be changed when there has been a change to the file. Should I be using grep? I fairly new to UNIX and was told to using something like... (2 Replies)
Discussion started by: mchelle_99
2 Replies

7. Solaris

Change passwd for bulk servers using SSH script

Hi, I need to Change passwd for bulk servers using SSH script. I have one server, from which i can reach all the servers without password via SSH. There is some expect script, from which i can achieve it. Can any one help me out here. Thanks in advance. Vicky (1 Reply)
Discussion started by: vickyingle5
1 Replies

8. Shell Programming and Scripting

Change /etc/passwd shell to telnet with parameters

Hello *nix users, I'm wondering if there's a way to change a user's default shell in /etc/passwd to the telnet program along with some parameters. For instance: user:x:1001:1001::/home/user:/usr/bin/telnet localhost 12345 The above line in the /etc/passwd file gives the following error... (2 Replies)
Discussion started by: tux0084
2 Replies

9. Shell Programming and Scripting

ksh script to change passwd

Hello All, I am trying to change a user passwd (one time password): cat /tmp/passwd mnop1234 mnop1234 #passwd abcd < /tmp/passwd (for some reason, it is not able to input the password from /tmp/passwd and comes back with "New Password: ") Is there a work around except using "expect". ... (1 Reply)
Discussion started by: solaix14
1 Replies

10. Shell Programming and Scripting

passwd in shell script

Is there a way to change user password using passwd command in shell script? I don't want to use expect. Please help (8 Replies)
Discussion started by: corny
8 Replies
Login or Register to Ask a Question