GeekInterview.com
  I am new, Sign me up!
 
GeekInterview.com  >  Interview Questions  >  Operating System  >  Shell Scripting
Go To First  |  Previous Question  |  Next Question 
 Shell Scripting  |  Question 23 of 47    Print  
How Connect to a Database in Shell Programming?Please tell me Step by Step?

  
Total Answers and Comments: 7 Last Update: January 14, 2009     Asked by: Brahma Reddy Thatiparthi 
  
 Sponsored Links

 
 Best Rated Answer

No best answer available. Please pick the good answer available or submit your answer.
April 06, 2006 09:59:04   #1  
Cool_Buddy Member Since: April 2006   Contribution: 1    

RE: How Connect to a Database in Shell Programming?Ple...

Which database u want to connect to ?


 
Is this answer useful? Yes | No
April 12, 2006 15:55:47   #2  
anjani.unix.help Member Since: April 2006   Contribution: 1    

RE: How Connect to a Database in Shell Programming?Ple...

Suppose you are using db2 and ksh

----------------------------

#!/usr/bin/ksh

connect to <Serve Name>:<Port NO>@<Instance Name> user <USERID> using <Passwd>

-----------------------------------

If u have profile and catalog then

----------------------------------

#!/usr/bin/ksh

db2 connect to <SID>

-----------------------------------

To run a sample proc .. use the below

db2 <Proc Name>

Thanks

an


 
Is this answer useful? Yes | No
April 19, 2006 10:26:21   #3  
vijay9849708008 Member Since: April 2006   Contribution: 1    

RE: How Connect to a Database in Shell Programming?Ple...
To Connect to Oracle Database and Collect the data in to text file from the table.echo Enter User Name read nameecho Enter passwd stty -echoread passstty echoecho Enter Detp no read dnosqlplus -S $name@oracle/$pass<
 
Is this answer useful? Yes | No
August 30, 2006 05:40:44   #4  
Ramakrishna.P        

RE: How Connect to a Database in Shell Programming?Ple...

Hi all

By using shell script

#!user/bin/bash

sqlplus ' / as sysdba ' >>EOF

startup

shutdown immediate >>EOF


 
Is this answer useful? Yes | No
March 25, 2007 20:05:00   #5  
cmanne Member Since: January 2006   Contribution: 49    

RE: How Connect to a Database in Shell Programming?Ple...
Hi
In oreder to connect to a database using a shell script it is always necessary to set the environment first and then connect to the database and execute whatever the statements u need to and come out of the script gracefully.

ex:
#!/bin/sh
export ORACLE_SID $1
export ORACLE_HOME more /etc/oratab|grep -v '#'|grep -i $1|cut -d":" -f2
export LD_LIBRARY_PATH $ORACLE_HOME/lib:/usr/lib
export PATH $ORACLE_HOME/bin:$HOME/bin:$PATH

sqlplus -s sys/<passwd> as sysdba <EOF
select name from v$database;
archive log list;
exit
EOF

The above script echoes the name of the database you are connected along with the archive log mode information.

 
Is this answer useful? Yes | No
October 27, 2008 20:30:04   #6  
jrgalaura Member Since: October 2008   Contribution: 3    

RE: How Connect to a Database in Shell Programming?Please tell me Step by Step?
To connect to sybase write this in the command line:

isql -Sservername -Uusername -Ppassword
1>use database
2>go

when you're done just type quit.

Although i don't recommend using the -P option as other people might see your password.

 
Is this answer useful? Yes | No
January 14, 2009 13:53:04   #7  
Vamshidhar Member Since: February 2008   Contribution: 4    

How Connect to a Database in Shell Programming?Please tell me Step by Step?
IF the Database is DB2 then the script is :
db2 "connect to $dbname user $userid using $password"

 
Is this answer useful? Yes | No


 
Go To Top


 Sponsored Links

 
About Us -  Privacy Policy -  Terms and Conditions -  Contact -  Ask Question -  Propose Category -  Site Updates 

Copyright © 2005 - 2009 GeekInterview.com. All Rights Reserved

Page copy protected against web site content infringement by Copyscape