# Problem in script when using variables

**URL:** <https://community.unix.com/t/problem-in-script-when-using-variables/215624>\
**Category:** UNIX for Advanced & Expert Users\
**Created:** [October 8, 2008, 7:29am UTC](https://community.unix.com/t/problem-in-script-when-using-variables/215624 "2008-10-08T07:29:27Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![palsevlohit\_123](https://community.unix.com/user_avatar/community.unix.com/palsevlohit_123/32/1053_2.png) [@palsevlohit\_123](https://community.unix.com/u/palsevlohit_123)\
**Post date:** [October 8, 2008, 7:29am UTC](https://community.unix.com/t/problem-in-script-when-using-variables/215624/1 "2008-10-08T07:29:27Z")

</div>

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....?

```nohighlight
> 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> 

```

---

<div class="post-metadata">

**Author:** ![Franklin52](https://community.unix.com/user_avatar/community.unix.com/franklin52/32/500_2.png) [@Franklin52](https://community.unix.com/u/Franklin52)\
**Post date:** [October 8, 2008, 7:42am UTC](https://community.unix.com/t/problem-in-script-when-using-variables/215624/2 "2008-10-08T07:42:45Z")

</div>

Assuming the name of the directory is /TCSDIR/scr

```nohighlight
start_path=/${AppName}DIR/src

```

Regards

---

<div class="post-metadata">

**Author:** ![palsevlohit\_123](https://community.unix.com/user_avatar/community.unix.com/palsevlohit_123/32/1053_2.png) [@palsevlohit\_123](https://community.unix.com/u/palsevlohit_123)\
**Post date:** [October 8, 2008, 8:17am UTC](https://community.unix.com/t/problem-in-script-when-using-variables/215624/3 "2008-10-08T08:17:31Z")

</div>

$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

---

<div class="post-metadata">

**Author:** ![era](https://community.unix.com/letter_avatar/era/32/6_449c533f586939b6e5f246632a46421f.png) [@era](https://community.unix.com/u/era)\
**Post date:** [October 8, 2008, 8:21am UTC](https://community.unix.com/t/problem-in-script-when-using-variables/215624/4 "2008-10-08T08:21:40Z")

</div>

You need to use eval to expand a variable inside another variable.

```nohighlight
eval echo $start_path

```

---

<div class="post-metadata">

**Author:** ![palsevlohit\_123](https://community.unix.com/user_avatar/community.unix.com/palsevlohit_123/32/1053_2.png) [@palsevlohit\_123](https://community.unix.com/u/palsevlohit_123)\
**Post date:** [October 8, 2008, 8:33am UTC](https://community.unix.com/t/problem-in-script-when-using-variables/215624/5 "2008-10-08T08:33:06Z")

</div>

Thanks, Its working.
