The UNIX and Linux Forums  

Go Back   The UNIX and Linux Forums > Top Forums > UNIX for Advanced & Expert Users
Google UNIX.COM


UNIX for Advanced & Expert Users Advanced UNIX and Linux questions go here. Expert-to-Expert.

More UNIX and Linux Forum Topics You Might Find Helpful
Thread Thread Starter Forum Replies Last Post
problem accessing Multiple Variables from C Program to a Shell script sameworld1980 Shell Programming and Scripting 1 09-10-2008 01:56 PM
problem with environment variables Naughtydj SUN Solaris 1 06-28-2008 02:27 AM
passing a variables value from the called script to calling script using ksh rajarkumar Shell Programming and Scripting 9 06-19-2008 02:33 PM
gdb problem viewing variables rimon HP-UX 0 11-21-2007 02:35 AM
problem with variables udi Shell Programming and Scripting 2 12-22-2001 11:14 PM

Reply
 
Submit Tools LinkBack Thread Tools Search this Thread Display Modes
  #1  
Old 10-08-2008
Registered User
 

Join Date: Aug 2008
Location: India
Posts: 108
Problem in script when using variables

The AppName may be TCS/HCL/SCB.
For All the above 3 i ill have exported TCSDIR/HCLDIR/SCBDIR in .profile with some path.
i'm cnstruct the path in script and trying to cd $VARIABLE, it shows "not found".

Any solution for this....?

Code:
> AppName="TCS"
> echo $AppName
TCS
> start_path="\$${AppName}DIR/src"
> echo $start_path
$TCSDIR/src
> cd $start_path
ksh: $TCSDIR/src:  not found
> cd $TCSDIR/src
/tmp/TCS_TEMP/src>
Reply With Quote
Forum Sponsor
  #2  
Old 10-08-2008
Moderator
 

Join Date: Feb 2007
Posts: 2,328
Assuming the name of the directory is /TCSDIR/scr

Code:
start_path=/${AppName}DIR/src
Regards
Reply With Quote
  #3  
Old 10-08-2008
Registered User
 

Join Date: Aug 2008
Location: India
Posts: 108
$TCSDIR is the env variable set in my .profile

so i'm creating that based on the input in my script.
When i'm using that in script i'm getting issue.

$TCSDIR is /tmp/TCS_TEMP which is exported in .profile
Reply With Quote
  #4  
Old 10-08-2008
era era is offline
Herder of Useless Cats
 

Join Date: Mar 2008
Location: /there/is/only/bin/sh
Posts: 3,650
You need to use eval to expand a variable inside another variable.

Code:
eval echo $start_path
Reply With Quote
  #5  
Old 10-08-2008
Registered User
 

Join Date: Aug 2008
Location: India
Posts: 108
Thanks, Its working.
Reply With Quote
Google The UNIX and Linux Forums
Reply

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes




All times are GMT -7. The time now is 03:17 PM.


Powered by: vBulletin, Copyright ©2000 - 2006, Jelsoft Enterprises Limited.
The UNIX and Linux Forums Content Copyright ©1993-2008. All Rights Reserved.Ad Management by RedTyger Visit The Complex Event Processing Blog

Content Relevant URLs by vBSEO 3.2.0