How great could it be if you could get informations about your server & database displayed directly when you connect using SSH?
Information such as...
- The name of the server you are connected to
- The $ORACLE_SID variable
- The status of the database
You want it, you have it!... Here is a small script that will test the status of your instance when you connect.
That is the code you have to use in your .bash_profile.started=`sqlplus -s login/passwd @/home/oracle/test.sql | grep "ACTIVE"`
stop=`sqlplus -s login/passwd @/home/oracle/test.sql | grep "ERROR"`
echo -e ""
echo -e "---------------------------------"
echo -en "Welcome to "
echo $HOSTNAME
echo -e "---------------------------------"
echo -e "Database informations:"
echo -n " - SID: "
echo $ORACLE_SID
echo -n " - Status: "
if test -n "$started"
then
echo "Started"
elif test -n "$stop"
then
echo "Stopped"
else
echo "Unknown"
fi
Next, just create a file named test.sql file in the home folder of the user.
The file will contain this query:
SELECT STATUS,
DATABASE_STATUS
FROM V$INSTANCE;
EXIT
And you're done! Just in time for the coffee.

Aucun commentaire:
Enregistrer un commentaire