Failed to export parameters from configuration file


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Failed to export parameters from configuration file
# 1  
Old 01-15-2006
Failed to export parameters from configuration file

Hi folks,

I have the following configuration file:
Code:
/tmp> cat nir.conf 
SCHEMA_NAME=NIR
SCHEMA_PASS=NIR
CGI_PORT=:7778
HOST_PORT=:7778 
COMPATIBLE=10.1.0
STATIC_FILES_INITIAL=core 
TIME_ZONE=-2
DAYLIGHT_SAVING_TIME=NULL
CP_PLUGIN_SUPPORTED=FALSE
CPPlugin=DefaultCPPlugin
REPLACE_BO_USER=NO

From this file I should generate "define" parameters file for sqlplus and exporting those parameters in ksh environment.
I wrothe the following script:
Code:
#! /bin/ksh

RESPONSE_FILE=/tmp/nir.conf
cat $RESPONSE_FILE | while read line
do
 echo "define $line" >> /tmp/def_var_DatabaseLayer.sql
 export $line
done
echo ${SCHEMA_NAME}

The problem is that the parameters are not exported:

Code:
/tmp> ./gen_param_files.ksh 

RESPONSE_FILE=/tmp/nir.conf
+ RESPONSE_FILE=/tmp/nir.conf
cat $RESPONSE_FILE | while read line
do
 echo "define $line" >> /tmp/def_var_DatabaseLayer.sql
 export $line
done
+ cat /tmp/nir.conf
+ read line
+ echo define SCHEMA_NAME=NIR
+ >> /tmp/def_var_DatabaseLayer.sql 
+ export SCHEMA_NAME=NIR
+ read line
+ echo define SCHEMA_PASS=NIR
+ >> /tmp/def_var_DatabaseLayer.sql 
+ export SCHEMA_PASS=NIR
+ read line
+ echo define CGI_PORT=:7778
+ >> /tmp/def_var_DatabaseLayer.sql 
+ export CGI_PORT=:7778
+ read line
+ echo define HOST_PORT=:7778
+ >> /tmp/def_var_DatabaseLayer.sql 
+ export HOST_PORT=:7778
+ read line
+ echo define COMPATIBLE=10.1.0
+ >> /tmp/def_var_DatabaseLayer.sql 
+ export COMPATIBLE=10.1.0
+ read line
+ echo define STATIC_FILES_INITIAL=core
+ >> /tmp/def_var_DatabaseLayer.sql 
+ export STATIC_FILES_INITIAL=core
+ read line
+ echo define TIME_ZONE=-2
+ >> /tmp/def_var_DatabaseLayer.sql 
+ export TIME_ZONE=-2
+ read line
+ echo define DAYLIGHT_SAVING_TIME=NULL
+ >> /tmp/def_var_DatabaseLayer.sql 
+ export DAYLIGHT_SAVING_TIME=NULL
+ read line
+ echo define CP_PLUGIN_SUPPORTED=FALSE
+ >> /tmp/def_var_DatabaseLayer.sql 
+ export CP_PLUGIN_SUPPORTED=FALSE
+ read line
+ echo define CPPlugin=DefaultCPPlugin
+ >> /tmp/def_var_DatabaseLayer.sql 
+ export CPPlugin=DefaultCPPlugin
+ read line
+ echo define REPLACE_BO_USER=NO
+ >> /tmp/def_var_DatabaseLayer.sql 
+ export REPLACE_BO_USER=NO
+ read line
echo ${SCHEMA_NAME}
+ echo

As you can see,${SCHEMA_NAME} is empty.
What did I do wrong?
Is there a better way to export parameters in loop according to configuration file?

Thanks in advance,
Nir
# 2  
Old 01-15-2006
not tested.....
Code:
#! /bin/ksh

RESPONSE_FILE=/tmp/nir.conf
. "${RESPONSE_FILE}"
sed 's/^/define /g' "${RESPONSE_FILE}" > /tmp/def_var_DatabaseLayer.sql
echo ${SCHEMA_NAME}

# 3  
Old 01-15-2006
Couple of problems there. Setting a variable is not the same as exporting a variable. Also he wanted to append.

RESPONSE_FILE=/tmp/nir.conf
export $(< $RESPONSE_FILE)
sed 's/^/define /' < $RESPONSE_FILE=/tmp/nir.conf >>/tmp/def_var_DatabaseLayer.sql
# 4  
Old 01-15-2006
Quote:
Originally Posted by Perderabo
Couple of problems there. Setting a variable is not the same as exporting a variable. Also he wanted to append.

RESPONSE_FILE=/tmp/nir.conf
export $(< $RESPONSE_FILE)
point taken - thanks, but......shouldn't
Quote:
Originally Posted by Perderabo
sed 's/^/define /' < $RESPONSE_FILE=/tmp/nir.conf >>/tmp/def_var_DatabaseLayer.sql
be
Code:
sed 's/^/define /' < $RESPONSE_FILE >>/tmp/def_var_DatabaseLayer.sql


Last edited by vgersh99; 01-15-2006 at 10:20 PM..
# 5  
Old 01-15-2006
Opps, yes it should. Smilie
# 6  
Old 01-16-2006
Perderabo and vgersh99,

Thanks a lot!
It works fantastic!

Best regards,
Nir
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

If the 1th column of file f1 and file f2 is the same, then export those line with maximum string of

please help to write a awk command-line programs to achieve the following functions: Thank in advance. Requeset Description: compare two files f1 and f2, export to file f3: 1 Delete duplicate rows of in file f1 and file f2 2 If the 1th column of file f1 and file f2 is the same, then export... (1 Reply)
Discussion started by: weichanghe2000
1 Replies

2. Shell Programming and Scripting

Shell Script to Dynamically Extract file content based on Parameters from a pdf file

Hi Guru's, I am new to shell scripting. I have a unique requirement: The system generates a single pdf(/tmp/ABC.pdf) file with Invoices for Multiple Customers, the format is something like this: Page1 >> Customer 1 >>Invoice1 + invoice 2 >> Page1 end Page2 >> Customer 2 >>Invoice 3 + Invoice 4... (3 Replies)
Discussion started by: DIps
3 Replies

3. Shell Programming and Scripting

Run a program-print parameters to output file-replace op file contents with max 4th col

Hi Friends, This is the only solution to my task. So, any help is highly appreciated. I have a file cat input1.bed chr1 100 200 abc chr1 120 300 def chr1 145 226 ghi chr2 567 600 unix Now, I have another file by name input2.bed (This file is a binary file not readable by the... (7 Replies)
Discussion started by: jacobs.smith
7 Replies

4. Shell Programming and Scripting

How to export the string to a text file.

Hi, I have used this find . -type f -exec grep "491629461544" {} \; > test.txt to find the string and export it to file. The problem is, when i used the above command in Shell script, the file is created but the searched string is recursively written in that file and even the file... (10 Replies)
Discussion started by: nanthagopal
10 Replies

5. AIX

wtmp file - is there a patch to export the data another file each day?

sorry for being a noob, i am trying to find which user accessed the server at what time and there ip address at first i used who command but the output didn't contain the ip address then i used the last command which provided me with the ip of the users but when i searched i searched and found that... (1 Reply)
Discussion started by: hercules_1010
1 Replies

6. Shell Programming and Scripting

help t export the variable from a particular file

Hello Guys, I need you help to do one task I have script which is actually doing to fetch the code of any repository in svn for e.g.:- I can use svn to checkout the repository but I want to checkout the repository for particular tag like svn co <url>/svn/repo/<tag-name> and this... (1 Reply)
Discussion started by: rohit22hamirpur
1 Replies

7. Shell Programming and Scripting

bash mysql export to file

I'm trying to export a mysql query to a .csv file, right now I'm running a successful query like: us_id=`mysql -u $USER_NAME --password=$PASSWORD -D "databasename" \ -e "SELECT * \ FROM databasename.table \ WHERE somefield >0 AND otherfield ='$ctry' \ ORDER BY... (1 Reply)
Discussion started by: unclecameron
1 Replies

8. AIX

tuning network parameters : parameters not persist after reboot

Hello, On Aix 5.2, we changed the parameters tcp_keepinit, tcp_keepintvl and tcp_keepidle with the no command. tunrestore -R is present in inittab in the directory /etc/tunables we can clearly see the inclusion of parameters during reboot, including the file lastboot.log ... (0 Replies)
Discussion started by: dantares
0 Replies

9. Shell Programming and Scripting

How to export a unix file to txt file?

Is there any way by which u can export a file in unix box to a notepad or txt file?:confused: (3 Replies)
Discussion started by: nohup
3 Replies

10. UNIX for Dummies Questions & Answers

How to export data file from Unix

Hi, I am searching a way to export data file on Unix to SQL server on a daily bases. Any one has any ideas? Thanks in advance! (20 Replies)
Discussion started by: whatisthis
20 Replies
Login or Register to Ask a Question