Windows batch script to check  if an oracle database and listener  is up

Posted on 2010-09-16
Last Modified: 2012-05-10
Hi experts,
I' m using windows 2008 server, I need  two DOS batch scripts  to check if an oracle database and listener  is up  and  to send an  e-mail alert which includes computer name, date/time and a message that DB  or Listener is down.  
Question by:orcun_turkec
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
  • 2

Assisted Solution

Bigboj earned 125 total points
ID: 33689601
To check if oracle is up:

@echo off
qprocess oracle.exe
if not ERRORLEVEL 0 goto :oracle_down
qprocess tnslsnr.exe
if not ERRORLEVEL 0 goto :listener_down

set MESS=Oracle is up and listening
goto mail

set MESS=oracle.exe not running
goto mail

set MESS=tnslsnr.exe not running
goto mail

echo %MESS%
rem Since Windows is not able to send a mail from command line, You
rem have to solve it by Yourself.
rem I personally use Blat:
LVL 77

Assisted Solution

by:slightwv (䄆 Netminder)
slightwv (䄆 Netminder) earned 375 total points
ID: 33691132
You will need to add one more step:  The only way to guarantee Oracle is working properly is to connect to it using sql*plus.

Oracle.exe can be running and the database can be down.

Author Comment

ID: 33691909
How can this be applied to a batch script   Slightwv ?

As Bigboj said, I wrote a batch script  as shown below ;

@echo off
qprocess oracle.exe
if not  ERRORLEVEL 0 goto :oracle_down
set MESS=%COMPUTERNAME% oracle.exe not  running
goto mail
echo %MESS%

How can the sqlplus command ( sqlplus sys/xxxx as sysdba )  can be applied to this script?
And what are other tools or scripts except Blat application for sending mail ?
LVL 77

Accepted Solution

slightwv (䄆 Netminder) earned 375 total points
ID: 33692337
Try the following code for sqlplus

for mail maybe a VBS script:

or powershell:
@echo off
echo username/password
echo whenever sqlerror exit failure
echo select 'Works' from dual;
) | sqlplus -s


Open in new window


Author Comment

ID: 33715752
Thank you

Featured Post

Enroll in May's Course of the Month

May’s Course of the Month is now available! Experts Exchange’s Premium Members and Team Accounts have access to a complimentary course each month as part of their membership—an extra way to increase training and boost professional development.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
PL/SQl Expanding the WHERE statement in query 3 54
Oracle perfomance issue. 4 49
oracle forms question 9 40
construct a query sql 11 43
Introduction A previously published article on Experts Exchange ("Joins in Oracle", makes a statement about "Oracle proprietary" joins and mixes the join syntax with gen…
When it comes to protecting Oracle Database servers and systems, there are a ton of myths out there. Here are the most common.
This video shows, step by step, how to configure Oracle Heterogeneous Services via the Generic Gateway Agent in order to make a connection from an Oracle session and access a remote SQL Server database table.
This video shows setup options and the basic steps and syntax for duplicating (cloning) a database from one instance to another. Examples are given for duplicating to the same machine and to different machines

734 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question