Operating System - HP-UX
1828390 Members
2705 Online
109977 Solutions
New Discussion

Oracle SQL script to display ORACLE users on a SAP system

 
Mr. John Kerr
Occasional Advisor

Oracle SQL script to display ORACLE users on a SAP system

Hi,
I am trying to write a script to display Oracle users in a SAP system for SOX compliance, i want to cron the script to run at the begining of every Month.
However the script doesnt seem to be working.

Any ideas, below is the script.
#!/usr/bin/csh
$(ORACLE_HOME)/bin/sqlplus / as sysdba < /dev/null
spool /tmp/oracle_users.txt
select username, account_status from dba_users;
spool off;
exit;
EOF

I hear and I forget. I see and I remember. I do and I understand
2 REPLIES 2
A. Clay Stephenson
Acclaimed Contributor

Re: Oracle SQL script to display ORACLE users on a SAP system

First make sure that your script can run from a shell as the cron'ed user. Unless there is an extremely compelling reason, I would not use csh. Under cron, which intentionally has a very sparse environment, ORACLE_HOME, ORACLE_SID, and essentially all but a handful of variables are not defined. Moreover PATH is extremely limited as well. You need to explicitly set and export any needed environment variables within the cron'ed script before you ever invoke sqlplus.
If it ain't broke, I can fix that.
Volker Borowski
Honored Contributor

Re: Oracle SQL script to display ORACLE users on a SAP system

I agree with Clay,

should go like this:
put in your ORACLE_SID for xxx
and adjust 102_64 to 920_64 if not upgraded yet.

This script by the way would normally not be ruanble as root, because root does not belong to group "dba" and will therefore never be able to connet as sysdba. So I guess you'll run it as orasid ?!

#!/usr/bin/csh
setenv ORACLE_SID xxx
setenv ORACLE_HOME /oracle/${ORACLE_SID}/102_64

${ORACLE_HOME}/bin/sqlplus ..... rest is ok

Volker