The UNIX and Linux Forums  
Hello and Welcome from United States to the UNIX and Linux Forums! Thank You for Visiting and Joining Our Global Community.

Go Back   The UNIX and Linux Forums > Top Forums > UNIX for Dummies Questions & Answers
.
google unix.com



UNIX for Dummies Questions & Answers If you're not sure where to post a UNIX or Linux question, post it here. All UNIX and Linux newbies welcome !!

More UNIX and Linux Forum Topics You Might Find Helpful
Thread Thread Starter Forum Replies Last Post
Export variable as number zeus101 Shell Programming and Scripting 2 10-16-2007 12:09 AM
export variable. its-ashish UNIX for Dummies Questions & Answers 5 02-20-2007 06:24 AM
How to export the Display variable FredSmith UNIX for Dummies Questions & Answers 1 06-19-2006 09:07 AM
Syntax to export any variable malaymaru Shell Programming and Scripting 5 05-17-2005 04:16 AM
Perl: export variable to shell oldtrash Shell Programming and Scripting 2 09-11-2003 10:23 PM

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

Join Date: Mar 2006
Posts: 4
Export command giving Variable Name vs the Value set for the Variable

I'm having an issue when I export within my program. I'm getting the variable name, not the variable value. I have a configuration file (config.txt) that has the values of the variables set as so:

Code:
set -a
export ARCHIVEPOSourceDir="/interfaces/po/log /interfaces/po/data"
export ARCHIVEPRSourceDir="/interfaces/pr/log /interfaces/pr/data"
Then I have a shell script that I'm passing the configuration file and the interface name to as follows:

./CleanUpFiles.sh -C config.txt -P ARCHIVEPO

and here's the code in CleanUpFile.sh:

Code:
#!/usr/bin/ksh
PROG_NAME=`basename $0`

Usage ()
{
 echo "Usage: $PROG_NAME -C ConfigFile(config.txt) -P ARCHIVE_Interface_Name" 
 exit 1
}

if [ $# -ne 4 ]
then
 Usage
fi

while getopts C:P: Opt
do
    case ${Opt} in
        C) INTERFACE_CONFIG_FILE=${OPTARG}
           ;;	
        P) ARCHIVE_Interface_Name=${OPTARG}
           ;;
        ?) Usage 
    esac
done

. ${INTERFACE_CONFIG_FILE} 

export SOURCEDIR=${ARCHIVE_Interface_Name}SourceDir
echo ${SOURCEDIR}
So I pass ARCHIVEPO as the value for ARCHIVE_Interface_Name parameter to CleanUpFiles.sh. When the program executes: export SOURCEDIR=${ARCHIVE_Interface_Name}SourceDir, my expectation was that it would give back the values, "/interfaces/po/log /interfaces/po/data", but instead I get back "ARCHIVEPOSourceDir". If I hard code the statement as:export SOURCEDIR=${ARCHIVEPOSourceDir}, then I correctly get back the values, "/interfaces/po/log /interfaces/po/data". I need to be able to pass it as a parameter though, because this code is going to be reused by different interfaces. Any suggestions on a way around this?

Thanks,
Les...
  #2 (permalink)  
Old 03-31-2006
Perderabo's Avatar
Perderabo Perderabo is offline Forum Staff  
Unix Daemon
  
 

Join Date: Aug 2001
Location: Ashburn, Virginia
Posts: 9,111
Try:
eval export SOURCEDIR=\$${ARCHIVE_Interface_Name}SourceDir
  #3 (permalink)  
Old 04-03-2006
ParNone ParNone is offline
Registered User
  
 

Join Date: Mar 2006
Posts: 4
Thank ya Perderabo! That worked!
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 08:29 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