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 Advanced & Expert Users
.
google unix.com



UNIX for Advanced & Expert Users Expert-to-Expert. Learn advanced UNIX, UNIX commands, Linux, Operating Systems, System Administration, Programming, Shell, Shell Scripts, Solaris, Linux, HP-UX, AIX, OS X, BSD.

More UNIX and Linux Forum Topics You Might Find Helpful
Thread Thread Starter Forum Replies Last Post
passing a variables value from the called script to calling script using ksh rajarkumar Shell Programming and Scripting 10 12-23-2008 02:51 AM
problem accessing Multiple Variables from C Program to a Shell script sameworld1980 Shell Programming and Scripting 1 09-10-2008 04:56 PM
problem with environment variables Naughtydj SUN Solaris 1 06-28-2008 05:27 AM
gdb problem viewing variables rimon HP-UX 0 11-21-2007 05:35 AM
problem with variables udi Shell Programming and Scripting 2 12-23-2001 02:14 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 10-08-2008
palsevlohit_123 palsevlohit_123 is offline
Registered User
  
 

Join Date: Aug 2008
Location: India-Chennai
Posts: 120
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>
  #2 (permalink)  
Old 10-08-2008
Franklin52 Franklin52 is online now Forum Staff  
Moderator
  
 

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

Code:
start_path=/${AppName}DIR/src
Regards
  #3 (permalink)  
Old 10-08-2008
palsevlohit_123 palsevlohit_123 is offline
Registered User
  
 

Join Date: Aug 2008
Location: India-Chennai
Posts: 120
$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
  #4 (permalink)  
Old 10-08-2008
era era is offline Forum Advisor  
Herder of Useless Cats (On Sabbatical)
  
 

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

Code:
eval echo $start_path
  #5 (permalink)  
Old 10-08-2008
palsevlohit_123 palsevlohit_123 is offline
Registered User
  
 

Join Date: Aug 2008
Location: India-Chennai
Posts: 120
Thanks, Its working.
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 11:20 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