Avatar of bibi92
bibi92
Flag for France

asked on 

catch connection oracle failed and write it in csv file

Hello,
If connection to a database is not possible I add to catch and write the line below but how is it possible in below shell script:
"US","Hostname","","","","","","","connection failed","date"


#!/bin/sh
for BASE in $(ps -ef | grep pmon | grep -v "grep" |  awk -F "pmon_"  '{print$2}')
do
export ORACLE_SID=$BASE
. oraenv $BASE
${ORACLE_HOME}/bin/sqlplus -S / as sysdba << !
SET TERMOUT OFF
SET VERIFY OFF


select '"'||'US'||'"'||','||'"'||SYS_CONTEXT('USERENV','HOST') ||'"'||','||'"'||instance_name||'"'||','||'"'||u.username||'"'||','||'"'||u.PROFILE||'"'||','||'"'||p.limit||'"'||','||'"' ||sysdate||'"'  from dba_users u, dba_profiles p, v\$instance, dual where u.profile=p.profile;


!
done

Open in new window

Thank you

regards 
Linux* ShellOracle DatabaseUnix OS

Avatar of undefined
Last Comment
slightwv (䄆 Netminder)

8/22/2022 - Mon