Re: Administration script to check DB

From: Ben Graham <bengraham_at_xsmail.com>
Date: 14 Sep 2004 09:05:27 -0700
Message-ID: <f858471c.0409140805.49b8c7aa_at_posting.google.com>


fbiguet_at_yahoo.fr (F. Biguet) wrote in message news:<c20c89f0.0409140218.357ed924_at_posting.google.com>...
> Hello,
>
> I want to create a generic script that connects to Oracle databases
> (from 7.3.4 to 9.2 version) with a guest user. This script should
> return 1 if connection is successful and 0 if not.
> My problem is due to the 3 requests for password when the connection
> fails. I can't find any option that allows to ask for password only
> one time.
>
> Has anyone already written a such script?
>
> Thank you in advance.
>
> Fanny

Hi Fanny,

Connect to SQL*Plus with the nolog option. This doesn't prompt for a username/password when it starts. You can then use the connect command to attempt the connection. This doesn't prompt three times if the connection fails. E.g.

C:\>sqlplus /nolog

SQL> connect guest/password_at_sid
ERROR:
ORA-12500: TNS:listener failed to start a dedicated server process SQL> Put all your connection tests in a script. E.g For windows. connect_test.sql:



set verify off
set head off

host del &4

connect &1/&2_at_&3
select 'TEST_WORKED' from dual

spool &4
/

spool off

exit


Have another scripts that then runs connect_test.sql and parses the output, E.g.:

test_con.bat



sqlplus /nolog _at_connect_test.sql user password sid log_file REM Parse the log_file looking for "TEST_WORKED"

There's probably a neater solution, but the use of nolog is the main point here I think.

Ben Received on Tue Sep 14 2004 - 18:05:27 CEST

Original text of this message