# How to pass values from one file to different scripts

**URL:** <https://community.unix.com/t/how-to-pass-values-from-one-file-to-different-scripts/179067>\
**Category:** UNIX for Dummies Questions & Answers\
**Created:** [December 14, 2007, 5:46pm UTC](https://community.unix.com/t/how-to-pass-values-from-one-file-to-different-scripts/179067 "2007-12-14T17:46:49Z")\
**Posts on this page:** 7\
**Page:** 1

<div class="post-metadata">

**Author:** ![pssandeep](https://community.unix.com/letter_avatar/pssandeep/32/6_22734026db12803ebb3e059622ac3534.png) [@pssandeep](https://community.unix.com/u/pssandeep)\
**Post date:** [December 14, 2007, 5:46pm UTC](https://community.unix.com/t/how-to-pass-values-from-one-file-to-different-scripts/179067/1 "2007-12-14T17:46:49Z")

</div>

Hi Gurus,

Iam new to Unix.  
I had a requirement where i should use a file for example  
Host.sh or Host.txt  
Host = 555.254.45.14  
username = aaaa  
pwd = SSSSSS123

And this file need to be used in different scripts.  
For example i have script1.sh

where i want to use the values of Host,username & pwd to connect

and similarly in other scripts like script2.sh and script3.sh

So, please provide any example scripts or other info

---

<div class="post-metadata">

**Author:** ![porter](https://community.unix.com/letter_avatar/porter/32/6_22734026db12803ebb3e059622ac3534.png) [@porter](https://community.unix.com/u/porter)\
**Post date:** [December 14, 2007, 5:48pm UTC](https://community.unix.com/t/how-to-pass-values-from-one-file-to-different-scripts/179067/2 "2007-12-14T17:48:34Z")

</div>

if you export them, any child script will see them.

Otherwise pass as command line arguments.

---

<div class="post-metadata">

**Author:** ![pssandeep](https://community.unix.com/letter_avatar/pssandeep/32/6_22734026db12803ebb3e059622ac3534.png) [@pssandeep](https://community.unix.com/u/pssandeep)\
**Post date:** [December 14, 2007, 5:55pm UTC](https://community.unix.com/t/how-to-pass-values-from-one-file-to-different-scripts/179067/3 "2007-12-14T17:55:34Z")

</div>

> [@porter](#):
>
> if you export them, any child script will see them.
> 
> Otherwise pass as command line arguments.

Can just give me example script  
how to export in shell script

---

<div class="post-metadata">

**Author:** ![porter](https://community.unix.com/letter_avatar/porter/32/6_22734026db12803ebb3e059622ac3534.png) [@porter](https://community.unix.com/u/porter)\
**Post date:** [December 14, 2007, 5:59pm UTC](https://community.unix.com/t/how-to-pass-values-from-one-file-to-different-scripts/179067/4 "2007-12-14T17:59:55Z")

</div>

contents of host.sh

```nohighlight
Host=555.254.45.14
username=aaaa
pwd=SSSSSS123

```

contents of script1.sh

```nohighlight
#!/bin/sh

. ./host.sh

# if they are needed by sub scripts then...
export Host
export username
export pwd

echo Host is $Host
echo username is $username
echo pwd is $pwd

..... use as appropriate ...

```

---

<div class="post-metadata">

**Author:** ![pssandeep](https://community.unix.com/letter_avatar/pssandeep/32/6_22734026db12803ebb3e059622ac3534.png) [@pssandeep](https://community.unix.com/u/pssandeep)\
**Post date:** [December 14, 2007, 6:09pm UTC](https://community.unix.com/t/how-to-pass-values-from-one-file-to-different-scripts/179067/5 "2007-12-14T18:09:35Z")

</div>

> [@porter](#):
>
> contents of host.sh
> 
> ```plaintext
> Host=555.254.45.14
> username=aaaa
> pwd=SSSSSS123
> 
> ```
> 
> contents of script1.sh
> 
> ```plaintext
> #!/bin/sh
> 
> . ./host.sh
> 
> # if they are needed by sub scripts then...
> export Host
> export username
> export pwd
> 
> echo Host is $Host
> echo username is $username
> echo pwd is $pwd
> 
> ..... use as appropriate ...
> 
> ```

wht exactly we should use here ". ./host.sh"  
complete path where host.sh is there or just space ./host.sh

Thanks fr ur prompt response  
iam naive in unix

---

<div class="post-metadata">

**Author:** ![pssandeep](https://community.unix.com/letter_avatar/pssandeep/32/6_22734026db12803ebb3e059622ac3534.png) [@pssandeep](https://community.unix.com/u/pssandeep)\
**Post date:** [December 14, 2007, 6:13pm UTC](https://community.unix.com/t/how-to-pass-values-from-one-file-to-different-scripts/179067/6 "2007-12-14T18:13:12Z")

</div>

> [@porter](#):
>
> contents of host.sh
> 
> ```plaintext
> Host=555.254.45.14
> username=aaaa
> pwd=SSSSSS123
> 
> ```
> 
> contents of script1.sh
> 
> ```plaintext
> #!/bin/sh
> 
> . ./host.sh
> 
> # if they are needed by sub scripts then...
> export Host
> export username
> export pwd
> 
> echo Host is $Host
> echo username is $username
> echo pwd is $pwd
> 
> ..... use as appropriate ...
> 
> ```

Thanks its working

---

<div class="post-metadata">

**Author:** ![porter](https://community.unix.com/letter_avatar/porter/32/6_22734026db12803ebb3e059622ac3534.png) [@porter](https://community.unix.com/u/porter)\
**Post date:** [December 14, 2007, 6:14pm UTC](https://community.unix.com/t/how-to-pass-values-from-one-file-to-different-scripts/179067/7 "2007-12-14T18:14:37Z")

</div>

> [@pssandeep](#):
>
> wht exactly we should use here ". ./host.sh"  
> complete path where host.sh is there or just space ./host.sh

dot space path-to-host.sh

the dot and space are part of the syntax for running a script in the current process.
