|
Home > Archive > Unix Shell > September 2007 > Config files in bash scripts?
You are viewing an archived Text-only version of the thread.
To view this thread in it's original format and/or if you want to reply to
this thread please [click here]
| Author |
Config files in bash scripts?
|
|
| Jables 2007-09-24, 7:23 pm |
| Is there a good way to read and process a config file in a bash
script. I want global variables defined in a configuration file in
the form variable = value then read into the bash script.
Thanks,
John Brunsfeld
| |
| Ed Morton 2007-09-24, 7:23 pm |
| Jables wrote:
> Is there a good way to read and process a config file in a bash
> script. I want global variables defined in a configuration file in
> the form variable = value then read into the bash script.
>
> Thanks,
> John Brunsfeld
>
In the config file "file":
var1=val1
var2=val2
....
then do this:
. file
Regards,
Ed.
| |
| Jables 2007-09-24, 7:23 pm |
| On Sep 24, 2:17 pm, Ed Morton <mor...@lsupcaemnt.com> wrote:
> Jables wrote:
>
>
> In the config file "file":
>
> var1=val1
> var2=val2
> ....
>
> then do this:
>
> . file
>
> Regards,
>
> Ed.
Hmmmmmm, so I just tried that
In a file name file:
var1=1
var2=2
var3=3
Then in a file called run.sh:
.. file
echo $var1
echo $var2
echo $var3
Output:
../run.sh: line 1: ????: command not found
Thanks,
JB
| |
| Ed Morton 2007-09-24, 7:23 pm |
| Jables wrote:
> On Sep 24, 2:17 pm, Ed Morton <mor...@lsupcaemnt.com> wrote:
>
>
>
> Hmmmmmm, so I just tried that
> In a file name file:
>
> var1=1
> var2=2
> var3=3
>
> Then in a file called run.sh:
>
> . file
> echo $var1
> echo $var2
> echo $var3
>
> Output:
> ./run.sh: line 1: ????: command not found
>
> Thanks,
> JB
>
"file" is a command you're "dot-executing". Just like executing any
other command, "file" has to be in a directory in your PATH or you need
to specify an explicit path when you invoke it. Change run.sh to:
.. ./file
echo "$var1"
echo "$var2"
echo "$var3"
Regards,
Ed.
| |
| Jables 2007-09-24, 7:23 pm |
| On Sep 24, 3:05 pm, Ed Morton <mor...@lsupcaemnt.com> wrote:
> Jables wrote:
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
> "file" is a command you're "dot-executing". Just like executing any
> other command, "file" has to be in a directory in your PATH or you need
> to specify an explicit path when you invoke it. Change run.sh to:
>
> . ./file
> echo "$var1"
> echo "$var2"
> echo "$var3"
>
> Regards,
>
> Ed.
Thanks, worked like a charm.
|
|
|
|
|