Add multiple parameters to environment file


 
Thread Tools Search this Thread
Top Forums UNIX for Dummies Questions & Answers Add multiple parameters to environment file
# 1  
Old 02-17-2012
Add multiple parameters to environment file

Hi,

I am connecting to oracle DB from a unix script and below is how I am logging in with the parameters. this works fine, but the script connects to the DB thrice in different places and everytime these parameters have to be mentioned... which increases the lines in my script. In order to reduce the lines in the script, I would like to add these parameters to the environment file (which contains the path details in an environment) in a single variable.

Below is the code:

PHP Code:
DATE_OF_RUN_DB=`sqlplus -s <<sqlEOF
$ORACLE_USERNAME/$ORACLE_PASSWORD@$ORACLE_DB
$ORA_DB_PARMS
set feedback off
set heading off
set linesize 5000
set pagesize 0
set echo off
whenever sqlerror exit failure
whenever oserror exit failure
SELECT TO_CHAR(MAX(LAST_RUN_DATE) +1,'YYYYMMDD') FROM LOAD_HISTORY WHERE ENV_ID='ENVID' AND STATUS_OF_RUN ='SUCCESS';
sqlEOF

I added the parameters below to the environment file as ORA_DB_PARMS like below. but it didn't work.

PHP Code:
cat env_file.ksh
 
export ORA_DB_PARMS
=
set feedback off
set heading off
set linesize 5000
set pagesize 0
set 
echo off
whenever sqlerror 
exit failure
whenever oserror 
exit failure 
Can some one help me how to add those parameters using a single variable in the environment file? I would like to add only one single variable called ORA_DB_PARMS which can contain all the parameters needed to connect to DB.

I am on Linux and my script is bash.

Thanks
# 2  
Old 02-17-2012
You don't really need to export this. All you want is a shell variable.

If you don't put the text in quotes, it won't know it's all supposed to be in the variable and interpret them line by line.

Code:
ORA_DB_PARMS="
set feedback off
set heading off
set linesize 5000
set pagesize 0
set echo off
whenever sqlerror exit failure
whenever oserror exit failure"

Code:
. oracleparams

sqlplus -s <<sqlEOF
$ORACLE_USERNAME/$ORACLE_PASSWORD@$ORACLE_DB
$ORA_DB_PARMS
SELECT TO_CHAR(MAX(LAST_RUN_DATE) +1,'YYYYMMDD') FROM LOAD_HISTORY WHERE ENV_ID='ENVID' AND STATUS_OF_RUN ='SUCCESS';
sqlEOF

This User Gave Thanks to Corona688 For This Post:
 
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Python passing multiple parameters to functions

Hi, I am a beginner in python programming. In my python script have a main function which calls several other functions. The main function gets its input by reading lines from a input text file. I call the main function for every line in input text file through a loop. def main(line): var1... (6 Replies)
Discussion started by: ctrld
6 Replies

2. Shell Programming and Scripting

Processing multiple files (environment setting)

Hello I posted on here a while ago about processing multiple files within a script. See original post below: I have a program cfxfrwb which is designed to remove headers from reports files. The cfxfrwb is located in the following directory /u01/efin/v40/live/bin I run the program against... (8 Replies)
Discussion started by: captainrhodes
8 Replies

3. Shell Programming and Scripting

How to run csh environment parameters from k-shell script?

Hi Guys, I need to run an alias from a k-shell script ,for example 10204, which points to : source $ORACLE_BASE/scripts/cshrc/10204/.cshrc Meaning , I need to run in my k-shell script with the env settings parameters of the alias. How to do it in k-shell? Thanks in advance, Nir (2 Replies)
Discussion started by: nir_s
2 Replies

4. UNIX for Dummies Questions & Answers

Use of grep with multiple parameters in shell scripts

I am learning how to write shell scripts and have come across an issue. I'm trying to write a script that looks for a directory called public_html, and if it finds one, to print the number of lines that contain applet tags (containing '<applet') in all files that end in either .html or .htm that... (7 Replies)
Discussion started by: feverdream
7 Replies

5. Shell Programming and Scripting

Question on passing multiple parameters in if

Hi All, My target is to find the list of orphan processes running and i issue the below command with some exception ids. ps -ef | egrep -v "root|system|admin" | awk '{if ($3 == 1) print $1",\t"$2",\t"$3}' but this will exclude the process having the word 'root' and executing under different... (1 Reply)
Discussion started by: Arunprasad
1 Replies

6. Shell Programming and Scripting

Add new parameters into a line, and redirect the line to other file

How can i add new parameters into a line, and redirect the line to other file? For example: 1.sh name:owner google:richard youtube:student I want a, for example 2.sh with: name:owner:description google:richard:search site youtube:student:video site In the 2.sh, I added a new column:... (7 Replies)
Discussion started by: rafazz
7 Replies

7. Shell Programming and Scripting

bash if loop for checking multiple parameters

Hello, I've got next problem: I want to examine at the beginning of a script in an if loop that: 1. Is there 4 parameters given 2. If first state is true then: is there switches -e and -d? 3. At the end, how can i indentify them as variebles regardlees to its order. I was thinking like... (2 Replies)
Discussion started by: szittyafergeteg
2 Replies

8. Shell Programming and Scripting

passing multiple files as parameters

hi all i am etl guy i have shell script that i use to do processing on file. the problem is that i want it to use on multiple files at same time is there any way of passing the file name since my all my filename start with samename like abc* p,ease let me know (4 Replies)
Discussion started by: er_zeeshan05
4 Replies

9. Shell Programming and Scripting

for loop logic with multiple parameters

hi, unix wizards, i have a question about the logic of my inner for loop below. first, what i am trying to do is to write a script called create_account that automatically creates mysql accounts. the user can provide a user_name or a group_id as an argument (and the script can take multiple... (1 Reply)
Discussion started by: ankimo
1 Replies

10. UNIX for Dummies Questions & Answers

Grep on multiple parameters

All, Is is possible to grep on two parameters in a file: ex: If data in a file(GROCERIES.TXT) were like this ABC GROCERIES 38-904949 16 987.89 Then grep would be grep '38-904040' '16' GROCERIES.TXT Thanks KP (5 Replies)
Discussion started by: kingofprussia
5 Replies
Login or Register to Ask a Question