ba6.us - Dave's Database Related Stuff

  • home
  • blog
  • books
  • projects
  • about
  • !
Home › Blogs › dmann's blog

Search

Tags

apex development funnies monitoring oracle performance perl rman sql sqlplus unix windows
more tags

Navigation

  • Feed aggregator

Recent blog posts

  • Oracle IN Condition and Multi Column Subqueries
  • SQL For Dinosaurs
  • Quickie script to run dbv on your database...
  • Permissions for Autotrace
  • Accuracy of PROFILER.SQL from Metalink Doc: 243755.1
  • Recording Oracle System Stats for historical analysis...
  • Shell Script to Run a SQLPLUS against all databases running on a server...
  • Viewing command line args with Solaris ps utility...
  • Orion IO Test Tool
  • Documented Hints available in 11.2...
more

Books

  • What Are Books?
  • Execution Plans
  • Application Express Tips
  • Copying Databases
  • Distributed Transactions
  • Instance Differences
  • Instance Info
  • Materialized Views
  • Operating System Monitoring
  • Perl
  • Perl and Oracle
  • PL/SQL
  • Real Time Monitoring of Oracle
  • SQL Profiles
  • SQLDeveloper for Non Dummies
  • Statistics
  • Tablespace Info
  • Unix Shell Scripting
  • User Security

RSS Feed - Blog Posts

Syndicate content

User login

  • Create new account
  • Request new password

Shell Script to Run a SQLPLUS against all databases running on a server...

dmann — Tue, 12/29/2009 - 14:33

#!/usr/bin/bash
#---------------------------------------------------------------------------
# Written by  : David Mann @ http://ba6.us
# Script Name : alldatafiles.sh
# Description : Provides list of all datafiles for each running database on 
#               on a machine
#---------------------------------------------------------------------------

ORATAB=/etc/oratab
echo "INSTANCE_NAME, FILE_NAME"

# Step through running instances
ps -ef | grep ora_smon_ | grep -v grep | cut -b61-70 | while read LINE
do
    # Assign the ORACLE_SID
    ORACLE_SID=$LINE
    export ORACLE_SID

    #Find ORACLE_HOME info for current instance
    ORATABLINE=`grep $LINE $ORATAB`
    ORACLE_HOME=`echo $ORATABLINE | cut -f2 -d:`
    export ORACLE_HOME
    LD_LIBRARY_PATH=$ORACLE_HOME/lib:/usr/lib
    export LD_LIBRARY_PATH

    # Put $ORACLE_HOME/bin into PATH and export.
    PATH=$ORACLE_HOME/bin:/bin:/usr/bin:/etc ; export PATH

    # Get SGA
    sqlplus -s "/ as sysdba" <<EOF
    SET HEADING OFF
    SET FEEDBACK OFF
    SET LINESIZE 3800
    SET TRIMSPOOL ON
    SET TERMOUT OFF
    SET SPACE 0
    SET PAGESIZE 0
    select (select instance_name from v\$instance) as DB_NAME,
           file_name
      from dba_data_files
     order by 2;
EOF

done
  • shell script
  • sqlplus
  • dmann's blog

Post new comment

The content of this field is kept private and will not be shown publicly.
  • Web page addresses and e-mail addresses turn into links automatically.
  • Allowed HTML tags: <a> <em> <strong> <cite> <code> <ul> <ol> <li> <dl> <dt> <dd>
  • Lines and paragraphs break automatically.

More information about formatting options

CAPTCHA
This question is for testing whether you are a human visitor and to prevent automated spam submissions.
3 + 2 =
Solve this simple math problem and enter the result. E.g. for 1+3, enter 4.


Cornify
  • home
  • blog
  • books
  • projects
  • about
  • !

Content Copyright 2006-2010. Links are copyright of respective owners.