Re: Oracle Password-Changing Script

From: Chris Hamilton <chamilton_at_sratech.com>
Date: 1995/08/28
Message-ID: <41ss8d$n93_at_news.cais.com>#1/1


Shannell...

You were looking for a script to change a users' password. Here is a script I wrote which can be called from a menu or the SQL*Plus command line to change a password. It makes sure that the user types it twice and they match before issuing the "ALTER USER" command.

START THE SCRIPT HERE...


rem *******************************************************************
rem Name:     set_pass.sql
rem Author:   Chris Hamilton, SRA Technologies, Inc.
rem Date:     27-Jan-94
rem Purpose:  This is a script to allow a user to change his/her
rem           Oracle password.  It spools out two files, xxx.tmp
rem           (containing the password-change command or a failure
rem           message), and run_pass.tmp, containing commands to run
rem           the tmp file and delete it.  Botm tmp files are deleted
rem           after the script runs.

rem Usage: sqlplus -s un/pw _at_$DBA/set_pass.sql
rem *******************************************************************

set heading off;
set feedback off;
set verify off;
set pagesize 0;
set linesize 79;
set termout on;

column ord noprint;

ttitle off;

prompt -------------------------------------------------;
prompt Oracle Password-Change Utility;
prompt -------------------------------------------------;
accept new_passwd1 char prompt " Enter your new password: " hide; accept new_passwd2 char prompt "Verify your new password: " hide;
prompt -------------------------------------------------;
prompt ;

rem Build the xxx.tmp file...

spool $HOME/xxx.tmp;

select 'alter user '||user||' identified by '||'&&new_passwd1'||';' from dual
where upper('&&new_passwd1') = upper('&&new_passwd2') union
select 'Your first and second new password entries did not match!' from dual
where upper('&&new_passwd1') != upper('&&new_passwd2');

spool off;

prompt ;

prompt --------------------------------------------------;
prompt Press [Enter] to continue or [Ctrl-C] to cancel...;
prompt --------------------------------------------------;
pause;

set termout off;

rem Build the run_pass.tmp file (to execute xxx.tmp)...

spool $HOME/run_pass.tmp;

select 0 ord,

'start $HOME/xxx.tmp'

from dual
where upper('&&new_passwd1') = upper('&&new_passwd2') union
select 1 ord,

'host rm $HOME/xxx.tmp'

from dual
order by 1;

spool off;

start $HOME/run_pass.tmp;

host rm $HOME/run_pass.tmp;

set termout on;

exit;



END OF THE SCRIPT... Hope you find this useful.

Chris

 Chris Hamilton               
 chamilton_at_sratech.com        
 SRA Technologies, Inc.       

 City of Washington Pipe Band Received on Mon Aug 28 1995 - 00:00:00 CEST

Original text of this message