dbTalk Databases Forums  

Administration script to check DB

comp.databases.oracle comp.databases.oracle


Discuss Administration script to check DB in the comp.databases.oracle forum.



Reply
 
Thread Tools Display Modes
  #1  
Old   
F. Biguet
 
Posts: n/a

Default Administration script to check DB - 09-14-2004 , 05:18 AM






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

Reply With Quote
  #2  
Old   
rob
 
Posts: n/a

Default Re: Administration script to check DB - 09-14-2004 , 08:53 AM







"F. Biguet" <fbiguet (AT) yahoo (DOT) fr> wrote

Quote:
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
You know that 7.3.4 is pre-historic and unsupported for years don't you?
I don't know what you exactly like to achieve but this might give you a
hint.
0 = success
1 = failure
Can't remember if "whenever sqlerror exit failure" exists in 7.3.4

== test.sql
myserver{oracle}# cat test.sql
whenever sqlerror exit failure

connect &1/&2@&3
exit
==
== Connect error ===
myserver{oracle}#sqlplus /nolog @test bla bla mydb

SQL*Plus: Release 8.1.7.0.0 - Production on Tue Sep 14 15:38:00 2004

(c) Copyright 2000 Oracle Corporation. All rights reserved.

ERROR:
ORA-01017: invalid username/password; logon denied

myserver{oracle}# echo $?
1
==
== Connect succeeds
myserver{oracle}# sqlplus /nolog @test system manager mydb

SQL*Plus: Release 8.1.7.0.0 - Production on Tue Sep 14 15:38:15 2004

(c) Copyright 2000 Oracle Corporation. All rights reserved.

Connected.
Disconnected from Oracle8i Enterprise Edition Release 8.1.7.4.0 - Production
With the Partitioning option
JServer Release 8.1.7.4.0 - Production
dtodbs1{oracle}# echo $?
0
==

Regards,
Rob




Reply With Quote
  #3  
Old   
Ben Graham
 
Posts: n/a

Default Re: Administration script to check DB - 09-14-2004 , 11:05 AM



fbiguet (AT) yahoo (DOT) fr (F. Biguet) wrote in message news:<c20c89f0.0409140218.357ed924 (AT) posting (DOT) google.com>...
Quote:
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@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@&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 @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


Reply With Quote
  #4  
Old   
Wario
 
Posts: n/a

Default Re: Administration script to check DB - 09-14-2004 , 01:43 PM



1. You did not say what OS, so let's assume UNIX. Create a script.

sqlplus -L user/password@oracle_sid << END_SQL
whenever sqlerror exit 1
select sysdate from dual;
END_SQL

if [ $? -eq 0 ]
then
echo Successful
else
echo Failed
fi

NOTE: The return code will be 1 only is logon was successful and
select statement fails. Which happens when the database is closed.

2. You will see a failed message everytime a logon fails.

Wario
Oracle DBA

Reply With Quote
  #5  
Old   
sybrandb@yahoo.com
 
Posts: n/a

Default Re: Administration script to check DB - 09-15-2004 , 02:46 AM



fbiguet (AT) yahoo (DOT) fr (F. Biguet) wrote in message news:<c20c89f0.0409140218.357ed924 (AT) posting (DOT) google.com>...
Quote:
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
No need for such a script. Oracle Enterprise Manager deals with this nicely.
and OEM already existed in the stone age.

Sybrand Bakker
Senior Oracle DBA


Reply With Quote
  #6  
Old   
F. Biguet
 
Posts: n/a

Default Re: Administration script to check DB - 09-16-2004 , 03:41 AM



Thank you very much for all those answers.
I think I will solve my problem soon with all these informations.

I work whit many oracle versions (even oldest one; what client wants,
we do!) on many configuration systems and I must simulate a oracle
connexion from a client PC for a monitoring tool.

Best regards,

Fanny

Reply With Quote
Reply




Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off



Powered by vBulletin Version 3.5.3
Copyright ©2000 - 2012, Jelsoft Enterprises Ltd.