The UNIX and Linux Forums  

Go Back   The UNIX and Linux Forums > Top Forums > Shell Programming and Scripting
.
google unix.com



Shell Programming and Scripting Post questions about KSH, CSH, SH, BASH, PERL, PHP, SED, AWK and OTHER shell scripts and shell scripting languages here.

More UNIX and Linux Forum Topics You Might Find Helpful
Thread Thread Starter Forum Replies Last Post
Export a file system with write permissions jredx Filesystems, Disks and Memory 7 05-27-2008 04:05 AM
Is it possible to re-export a exported NFS file system? Adams Nave Filesystems, Disks and Memory 5 03-15-2008 01:40 AM
Failed to get value from a file using sed command nir_s Shell Programming and Scripting 2 03-11-2006 05:53 PM
How to export data file from Unix whatisthis UNIX for Dummies Questions & Answers 20 03-03-2005 02:16 PM
Editing file during running ksh in HP failed nir_s Shell Programming and Scripting 2 08-05-2004 09:50 AM

Closed Thread
English Japanese Spanish French German Portuguese Italian Dutch Swedish Russian Norwegian Hungarian Hebrew Danish Bulgarian Greek Powered by Powered by Google
 
LinkBack Thread Tools Search this Thread Rate Thread Display Modes
  #1 (permalink)  
Old 01-15-2006
nir_s nir_s is offline
Registered User
  
 

Join Date: Jun 2004
Posts: 148
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 (permalink)  
Old 01-15-2006
vgersh99's Avatar
vgersh99 vgersh99 is offline Forum Staff  
Moderator
  
 

Join Date: Feb 2005
Location: Boston, MA
Posts: 5,122
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 (permalink)  
Old 01-15-2006
Perderabo's Avatar
Perderabo Perderabo is online now Forum Staff  
Unix Daemon
  
 

Join Date: Aug 2001
Location: Ashburn, Virginia
Posts: 9,124
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 (permalink)  
Old 01-15-2006
vgersh99's Avatar
vgersh99 vgersh99 is offline Forum Staff  
Moderator
  
 

Join Date: Feb 2005
Location: Boston, MA
Posts: 5,122
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 (permalink)  
Old 01-15-2006
Perderabo's Avatar
Perderabo Perderabo is online now Forum Staff  
Unix Daemon
  
 

Join Date: Aug 2001
Location: Ashburn, Virginia
Posts: 9,124
Opps, yes it should.
  #6 (permalink)  
Old 01-16-2006
nir_s nir_s is offline
Registered User
  
 

Join Date: Jun 2004
Posts: 148
Perderabo and vgersh99,

Thanks a lot!
It works fantastic!

Best regards,
Nir
Closed Thread

Bookmarks

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On




All times are GMT -4. The time now is 09:15 AM.


Powered by: vBulletin, Copyright ©2000 - 2006, Jelsoft Enterprises Limited. Language Translations Powered by .
vBCredits v1.4 Copyright ©2007 - 2008, PixelFX Studios
The UNIX and Linux Forums Content Copyright ©1993-2009. All Rights Reserved.Ad Management by RedTyger

Content Relevant URLs by vBSEO 3.2.0