Calling DB user from separate file in Shell script


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Calling DB user from separate file in Shell script
# 1  
Old 05-23-2011
Calling DB user from separate file in Shell script

Hi All,

I need to execute a SQL via shell script and i am connecting to Oracle DB by this way $USERNAME1/$PASSWORD1@$STRING1 and i need to get username, password and string from someother file stored in the Unix Directory. $Username, $Password and $String is stored in File A in Path A and i want to call it in the test.sh in Path B.

Format of File A.txt

Username=test_db
Password=*****
Instance=ORACLEDB

Require your assistance!!!

Regards,
Sathish
# 2  
Old 05-23-2011
So ?

What is the problem you have ?

How to parse the input file to get username,password & instance into variables ?

How to make an SQL call from shell ?
# 3  
Old 05-24-2011
Hi,

I need to know the way to get the username and password from the other file. How to call that file and get the required values for SQL call??
# 4  
Old 05-24-2011
Code:
user@host> (/home/user) $ cat test1.txt
Username=test_db
Password=*****
Instance=ORACLEDB
user@host> (/home/user) $ cat  test.sh
user=`awk -F\= '/Username/{print $2}' test1.txt`
echo $user

user@host> (/home/user) $ cat test1.txt
user@host> (/home/user) $ ./test.sh
test_db
user@host> (/home/user) $

This is a way you can access your params from other file. And for sql you can use sqlplus /isql.
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

unable to pass value to user prompt from calling shell script

This is my script structure main script calls configure script which needs to be run as a different user and the configure script calls my application installation script. the application instruction script prompts the user for a directory which I need to pass from my main or configure script. ... (4 Replies)
Discussion started by: cmastays
4 Replies

2. UNIX for Advanced & Expert Users

shell script to send separate mails to different users from a text file

Hi Friends, Could you guys help me out of this problem... I need to send an email to all the users and the email has to be picked from the text file. text file contains the no. of records like: Code: giridhar 224285 847333 giridhar276@gmail.com ramana 84849 33884... (0 Replies)
Discussion started by: giridhar276
0 Replies

3. UNIX for Dummies Questions & Answers

need assistance on Calling DB user from separate file in Shell script

Hi All, I need to execute a SQL via shell script and i am connecting to Oracle DB by this way $USERNAME1/$PASSWORD1@$STRING1 and i need to get username, password and string from someother file stored in the Unix Directory. $Username, $Password and $String is stored in File A in Path A and i want... (1 Reply)
Discussion started by: sathish.tn
1 Replies

4. Shell Programming and Scripting

shell script hangs while calling sql file

I have a master shell script which calls some 40 shell scripts. All the shell scripts calls a sql file which executes some sql statements. I run these scripts in parallel such that it saves me time. When i executed them i saw some strange behavior. Firstly, I found that some scripts among the 40... (1 Reply)
Discussion started by: sushi
1 Replies

5. Shell Programming and Scripting

Calling sql file from shell script with parameters.

Hi, I am calling a sql file script.sql from shell script and passing few parameters also as shown below: sqlplus -S id/password @script.sql $param1 $param2 Now,In sql file I have to create a extract text file after querying oracle tables based on the parameters passed(param1,param2) as... (7 Replies)
Discussion started by: anil029
7 Replies

6. Shell Programming and Scripting

calling a sql file in my shell script

Hi, I want to call a sql file in my shell script. see the below code:- if ] then ( isql -U${S_USER} -S${S_SERV} -w100 -b -h0 <<ENDSQL | sed -e "s/Password://" ${S_PWD} set nocount on go use ${S_DB} go // need to call a file name... (16 Replies)
Discussion started by: dazdseg
16 Replies

7. UNIX for Advanced & Expert Users

Calling sql file from shell script

Hi I have a shell script that call a sql file. The sql file will create a spool file. My requirement is, when ever i get an OS error like file not found. I have to log it in a log file. Could some who worked in a like scenario help me by giving the code sample. Many Thanks.. (1 Reply)
Discussion started by: chintapalli001
1 Replies

8. Shell Programming and Scripting

calling a cgi file from shell script????

Hi.. Is it possible to call a cgi program which is used to display a pop up message in the else part...On executing the script it directly prints the source code of the pop up screen.. Please if you have any idea,share with us.Thanks. #start success250=`grep -c failure... (1 Reply)
Discussion started by: elavv
1 Replies

9. Shell Programming and Scripting

calling sql file from shell script

Hello everybody I need help calling sql file from shell script. Can anyone help me creating a small shell script which calls an sql file . The .sql file should contain some select statements like select emp_no from emp_table; select emp_id from emp_table; And the results should be... (6 Replies)
Discussion started by: dummy_needhelp
6 Replies

10. Shell Programming and Scripting

Problem with Calling sql file from shell script

I have created abc.sh file which will set the environment variables (UNIX env variables as well as ORACLE required variables like ORACLE_SID,ORACLE_HOME etc) and then calls a function file which checks for starts some logs and then it will try to execute the .sql file. The .sh, function file are as... (1 Reply)
Discussion started by: sskc
1 Replies
Login or Register to Ask a Question