Sponsored Content
Top Forums Shell Programming and Scripting Shell script verify connection to Oracle if not successful Post 303032918 by wtolentino on Tuesday 26th of March 2019 03:39:36 PM
Old 03-26-2019
Shell script verify connection to Oracle if not successful

i have a script that connects to the oracle database and executes the query statements. it works fine and i would like to add some message to check if the connection to oracle is not successful.

basically this is the code snippet:
Code:
#!/bin/sh
...
...
...
sqlplus -s username/password@dbName <<EOF > script.log
...
...
...
EOF
exit

how do I add it on the script?

thank you.
 

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

shell script- oracle connection problem

Hi all, I am having problem with a shell script. I have a couple of csv files. The shell script will do some operation on them, create a sql file which will then be called by sqlplus. The problem is to gracefully exit sqlplus at the end of every operation as I do not want to hang on to the... (4 Replies)
Discussion started by: nattynatty
4 Replies

2. Solaris

Can before and after snapshots be used to verify successful filesystem restoration?

Hello Guys, Can before and after snapshots be used to verify successful filesystem restoration? snapshots will be created using fssnaps and restoration is thru legato restore? Any ideas on this? or any other ways I could verify that restoration is good? Regards (0 Replies)
Discussion started by: MarkyBoy
0 Replies

3. Shell Programming and Scripting

oracle connection from shell script

Hi, For connecting to oracle my script is using the command sqlplus username/password@db_instance_name.For this to work i am setting ORACLE_HOME,TNS_ADMIN and ORACLE_SID in a seperate script.My question is,could we make a connection to oracle just by the command sqlplus... (4 Replies)
Discussion started by: DILEEP410
4 Replies

4. UNIX for Advanced & Expert Users

Connection closing immediatly after successful login

When ssh'ing into certain Unix boxes I'm seeing two errors that appear immediately after entering the password I've never seen. After the error message is displayed the connection closes immediately. The first is “/bin/ksh: Not owner” after which the connection is closed. And, “Read from remote... (2 Replies)
Discussion started by: twk
2 Replies

5. Shell Programming and Scripting

Verifying oracle connection from shell script

Hi, Oracle 9.2 Solaris 10 From the shell script ........How can we verify whether oracle connection is successful or not ? Shell script will prompt the user to enter the oracle schema username, password and tns name. So, *how to verify whether oracle connection has been established or... (14 Replies)
Discussion started by: milink
14 Replies

6. Shell Programming and Scripting

How the user will provide the parameters for Oracle db connection in a shell script?

I'm new into unix. My question: is possible to write a shell script which will ask for the ORACLE_HOME, ORACLE_SID, USERNAME, PASSWORD to connect to Oracle db. In generally we have to set the ORACLE_HOME in .profile file. And after putting the 'sqlplus' command it asks for the username &... (6 Replies)
Discussion started by: priya001
6 Replies

7. Shell Programming and Scripting

How to setup Oracle connection inside shell script?

Hi, We have Oracle Connection parameters set up in file name "TESTDB" at location /abc/etc.When I try to run my shell script it does not connect to Oracle database. Please let me know how "TESTDB" file can be called inside script. ####################### Setting the directories... (2 Replies)
Discussion started by: sandy162
2 Replies

8. UNIX for Dummies Questions & Answers

How to fix connection to Oracle database through shell script?

I have a question regarding how to connect to Oracle Database through shell script. 1. If I want call a stored procedure on Linux server as this, it works. $sqlplus /nolog SQL*Plus: Release 12.1.0.2.0 Production on Fri Jun 12 14:49:49 2015 Copyright (c) 1982, 2014, Oracle. All rights... (2 Replies)
Discussion started by: duke0001
2 Replies

9. Shell Programming and Scripting

How to check the status of sftp connection is successful or not in Linux?

Hi All, We are working on linux with putty terminal for file transferring using SFTP server... here we want to know /We have Urgent Requirement If SFTP connection is successfull then we should get .txt log file in target locaton as "Success/Failure" Please provide batch script for above... (7 Replies)
Discussion started by: sravanreddy
7 Replies

10. UNIX for Beginners Questions & Answers

Shell script is hanging up every time even after it's successful

We are using a korn shell script which is meant to trigger a Oracle job to load the data from a flat file to an Oracle database . Also the same script addresses the following tasks also like triggering a SFTP job to pick the file from one path to the target location and checking the same with... (6 Replies)
Discussion started by: senmng
6 Replies
MQdb::Database(3pm)					User Contributed Perl Documentation				       MQdb::Database(3pm)

NAME - MQdb::Database
DESCRIPTION
Generalized handle on an DBI database handle. Used to provide an instance which holds connection information and allows a higher level get_connection/ disconnect logic that persists above the specific DBI connections. Also provides a real object for use with the rest of the toolkit. SUMMARY
MQdb::Database provides the foundation of the MappedQuery system. Databases are primarily specified with a URL format. The URL format includes specification of a driver so this single method can select among the supported DBD drivers. Currently the system supports MYSQL, Oracle, and SQLite. The URL also allows the system to provide the foundation for doing federation of persisted objects. Each DBObject contains a pointer to the Database instance where it is stored. With the database URL and internal database ID, each object is defined in a global space. Attributes of MQdb::Database driver : mysql, oracle, sqlite (default mysql) user : username if the database requires password : password if the database requires host : hostname of the database server machine port : IP port of the database if required (mysql default is 3306) dbname : database/schema name on the database server for sqlite, this is the database file Example URLS mysql://<user>:<pass>@<host>:<port>/<database_name> mysql://<host>:<port>/<database_name> mysql://<user>@<host>:<port>/<database_name> mysql://<host>/<database_name> oracle://<user>:<pass>@/<database_name> oracle://<user>:<pass>@<host>:<port>/<database_name> sqlite:///<database_file> CONTACT
Jessica Severin <jessica.severin@gmail.com> LICENSE
* Software License Agreement (BSD License) * MappedQueryDB [MQdb] toolkit * copyright (c) 2006-2009 Jessica Severin * All rights reserved. * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are met: * * Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * * Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in the * documentation and/or other materials provided with the distribution. * * Neither the name of Jessica Severin nor the * names of its contributors may be used to endorse or promote products * derived from this software without specific prior written permission. * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS ''AS IS'' AND ANY * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE * DISCLAIMED. IN NO EVENT SHALL COPYRIGHT HOLDERS BE LIABLE FOR ANY * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. APPENDIX
The rest of the documentation details each of the object methods. Internal methods are usually preceded with a _ new Description: instance creation method Parameter : a hash reference of options same as attribute methods Returntype : instance of this Class (subclass) Exceptions : none new Description: instance creation method Returntype : instance of this Class (subclass) Exceptions : none init Description: initialization method which subclasses can extend Returntype : $self Exceptions : subclass dependent new_from_url Description: primary instance creation method Parameter : a string in URL format Returntype : instance of MQdb::Database Examples : my $db = MQdb::Database->new_from_url("mysql://<user>:<pass>@<host>:<port>/<database_name>"); e.g. mysql://<host>:<port>/<database_name> e.g. mysql://<user>@<host>:<port>/<database_name> e.g. mysql://<host>/<database_name> e.g. sqlite:///<database_file> my $class = shift; Exceptions : none copy Description: makes a copy of the database configuration. New instance will have its own database connection Returntype : instance of MQdb::Database dbc Description: connects to database and returns a DBI connection Returntype : DBI database handle Exceptions : none disconnect Description: disconnects handle from database, but retains object and all information so that it can be reconnected again at a later time. Returntype : none Exceptions : none full_url Description: returns the URL of this database with user and password Returntype : string Exceptions : none url Description: returns URL of this database but without user:password used for global referencing and federation systems Returntype : string Exceptions : none xml Description: returns XML of this database but without user:password used for global referencing and federation systems Returntype : string Exceptions : none execute_sql Description : executes SQL statement with external parameters and placeholders Example : $db->execute_sql("insert into table1(id, value) values(?,?)", $id, $value); Parameter[1] : sql statement string Parameter[2..] : optional parameters for the SQL statement Returntype : none Exceptions : none do_sql Description : executes SQL statement with "do" and no external parameters Example : $db->do_sql("insert into table1(id, value) values(null,'hello world');"); Parameter : sql statement string with no external parameters Returntype : none Exceptions : none fetch_col_value Arg(1) : $sql (string of SQL statement with place holders) Arg (2...) : optional parameters to map to the placehodlers within the SQL Example : $value = $self->fetch_col_value($db, "select some_column from my_table where id=?", $id); Description: General purpose function to allow fetching of a single column from a single row. Returntype : scalar value Exceptions : none Caller : within subclasses to easy development perl v5.10.0 2009-05-30 MQdb::Database(3pm)
All times are GMT -4. The time now is 09:06 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy