Identify the datafiles in number of hosts in hostfile

for host in `cat ~oracle/.rhosts|
cut -d”.” -f1|awk ‘{print $1}’|sort -u`
do
    echo ” “
    echo “************************”
    echo “$host”
    echo “************************”
    # loop from database to database
    for db in `cat /etc/oratab|egrep ‘:N|:Y’|
      grep -v *|grep ${db}|cut -f1 -d’:'”`
    do
        home=`rsh $host “cat /etc/oratab|egrep ‘:N|:Y’|
          grep -v *|grep ${db}|cut -f2 -d’:'”`
        echo “************************”
        echo “database is $db”
        echo “************************”
        rsh $host “
        ORACLE_SID=${db}; export ORACLE_SID;
        ORACLE_HOME=${home}; export ORACLE_HOME;
        ${home}/bin/sqlplus -s /<<!
        set pages 9999;
        set heading off;
        select name from v”””$”datafile;
        exit
        !”
    done
done
  • September 29, 2016 | 14 views