# Error in calling a shell script from another script

**URL:** <https://community.unix.com/t/error-in-calling-a-shell-script-from-another-script/297110>\
**Category:** Shell Programming and Scripting\
**Created:** [October 13, 2011, 2:15am UTC](https://community.unix.com/t/error-in-calling-a-shell-script-from-another-script/297110 "2011-10-13T02:15:28Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![banupriyat](https://community.unix.com/letter_avatar/banupriyat/32/6_449c533f586939b6e5f246632a46421f.png) [@banupriyat](https://community.unix.com/u/banupriyat)\
**Post date:** [October 13, 2011, 2:15am UTC](https://community.unix.com/t/error-in-calling-a-shell-script-from-another-script/297110/1 "2011-10-13T02:15:28Z")

</div>

HI,

We are using two shell scripts, script.sh,env.sh, where env.sh will be called inside script.sh. The variable inside env.sh is used as $var in script.sh.But while running the script its not identifying that variable. Is there any permission needed to call a script inside another script.

The script.sh will have something like

```nohighlight
sh /path/env.sh
sh $var/runWF.sh

```

The script env.sh is having

```nohighlight
export var=/rootpath

```

The error we got is

```nohighlight
/runWF.sh not found

```

Please help

Thanks in advance  
Priya

---

<div class="post-metadata">

**Author:** ![ahamed101](https://community.unix.com/user_avatar/community.unix.com/ahamed101/32/1118_2.png) [@ahamed101](https://community.unix.com/u/ahamed101)\
**Post date:** [October 13, 2011, 2:20am UTC](https://community.unix.com/t/error-in-calling-a-shell-script-from-another-script/297110/2 "2011-10-13T02:20:12Z")

</div>

Try this...

```nohighlight
. /path/env.sh
sh $var/runWF.sh

```

--ahamed

---

<div class="post-metadata">

**Author:** ![clx](https://community.unix.com/letter_avatar/clx/32/6_449c533f586939b6e5f246632a46421f.png) [@clx](https://community.unix.com/u/clx)\
**Post date:** [October 13, 2011, 2:20am UTC](https://community.unix.com/t/error-in-calling-a-shell-script-from-another-script/297110/3 "2011-10-13T02:20:26Z")

</div>

Calling script inside the script would invoke another shell which doesn't return the environment back to the parent shell after execution.

You should use the source.

```nohighlight
source /path/env.sh

or 

. /path/env.sh

```

---

<div class="post-metadata">

**Author:** ![banupriyat](https://community.unix.com/letter_avatar/banupriyat/32/6_449c533f586939b6e5f246632a46421f.png) [@banupriyat](https://community.unix.com/u/banupriyat)\
**Post date:** [October 13, 2011, 2:30am UTC](https://community.unix.com/t/error-in-calling-a-shell-script-from-another-script/297110/4 "2011-10-13T02:30:40Z")

</div>

Its working.. Thanks... 🙂
