# Script Parameter Pass to Another Script

**URL:** <https://community.unix.com/t/script-parameter-pass-to-another-script/374740>\
**Category:** UNIX for Beginners Q & A\
**Created:** [February 4, 2019, 8:57am UTC](https://community.unix.com/t/script-parameter-pass-to-another-script/374740 "2019-02-04T08:57:28Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![wtolentino](https://community.unix.com/letter_avatar/wtolentino/32/6_22734026db12803ebb3e059622ac3534.png) [@wtolentino](https://community.unix.com/u/wtolentino)\
**Post date:** [February 4, 2019, 8:57am UTC](https://community.unix.com/t/script-parameter-pass-to-another-script/374740/1 "2019-02-04T08:57:28Z")

</div>

How do I pass a parameter from one script to another script?

dbParam.ini

```nohighlight
pUser=Magic
pPwd=Test1234
pNewPwd=HappyMeal

```

sample2.sh

```nohighlight
#!/usr/bin/ksh
. .dbParam.ini
echo "user $pUser"
echo "current password $pPwd"
echo "new password $pNewPwd"

```

when run

```nohighlight
$ sh sample2.sh
sample2.sh: line 2: .: .dbParam.ini: file not found
user
current password
new password

```

how do I pass a parameter from one script to another script? thanks.

---

<div class="post-metadata">

**Author:** ![nezabudka](https://community.unix.com/letter_avatar/nezabudka/32/6_22734026db12803ebb3e059622ac3534.png) [@nezabudka](https://community.unix.com/u/nezabudka)\
**Post date:** [February 4, 2019, 9:07am UTC](https://community.unix.com/t/script-parameter-pass-to-another-script/374740/2 "2019-02-04T09:07:14Z")

</div>

change the string  
`. .dbParam.ini`  
on  
`. dbParam.ini`

---

<div class="post-metadata">

**Author:** ![wtolentino](https://community.unix.com/letter_avatar/wtolentino/32/6_22734026db12803ebb3e059622ac3534.png) [@wtolentino](https://community.unix.com/u/wtolentino)\
**Post date:** [February 4, 2019, 9:25am UTC](https://community.unix.com/t/script-parameter-pass-to-another-script/374740/3 "2019-02-04T09:25:57Z")

</div>

it did not work.

```nohighlight
sh sample2.sh
sample2.sh: line 2: .: dbParam.ini: file not found
user
current password
new password

```

--- Post updated at 09:25 AM ---

I got it working by changing this line

```nohighlight
. .dbParam.ini

```

to

```nohighlight
. ./bParam.ini

```

sample2.sh

```nohighlight
. ./dbParam.ini
echo "user $pUser"
echo "current password $pPwd"
echo "new password $pNewPwd"

```

when run

```nohighlight
sh sample2.sh
user Magic
current password Test1234
new password HappyMeal

```

---

<div class="post-metadata">

**Author:** ![bakunin](https://community.unix.com/letter_avatar/bakunin/32/6_22734026db12803ebb3e059622ac3534.png) [@bakunin](https://community.unix.com/u/bakunin)\
**Post date:** [February 4, 2019, 11:05am UTC](https://community.unix.com/t/script-parameter-pass-to-another-script/374740/4 "2019-02-04T11:05:33Z")

</div>

> [@wtolentino](#):
>
> How do I pass a parameter from one script to another script?  
> sample2.sh
> 
> ```plaintext
> #!/usr/bin/ksh
> . .dbParam.ini
> echo "user $pUser"
> echo "current password $pPwd"
> echo "new password $pNewPwd"
> 
> ```
> 
> when run
> 
> ```plaintext
> sample2.sh: line 2: .: .dbParam.ini: file not found
> 
> ```

The problem is not the passing of a parameter from one script to another it is the usage of relative pathes in scripts. The line:

```plaintext
. .dbParam.ini

```

is problematic because the validity of relative pathes (here "." or the current directory) is depending on what exactly "the current directory" represents. Try replacing the line with:

```plaintext
. /the/path/to/.dbParam.ini

```

and it will work regardless of where you right now are when you call the script.

I hope this helps.

bakunin

---

<div class="post-metadata">

**Author:** ![nezabudka](https://community.unix.com/letter_avatar/nezabudka/32/6_22734026db12803ebb3e059622ac3534.png) [@nezabudka](https://community.unix.com/u/nezabudka)\
**Post date:** [February 4, 2019, 1:16pm UTC](https://community.unix.com/t/script-parameter-pass-to-another-script/374740/5 "2019-02-04T13:16:21Z")

</div>

> [@wtolentino](#):
>
> it did not work.  
> ...  
> I got it working by changing this line
> 
> ```plaintext
> . .dbParam.ini
> 
> ```
> 
> to
> 
> ```plaintext
> . ./bParam.ini
> 
> ```

Apparently you deleted the wrong point. 🙂  
Try neatly deleting the point and slash just before the file name ./dbParam.ini ,  
leaving only the first dot a space and then the file name `. dbParam.ini`  
Save and exit. Run your script again and share the results please
