tags:

views:

50

answers:

1

I am fairly inexperienced with shell(csh in this case) scripts but was asked to edit one. I was asked to add a config file to make it much simpler to edit several specific variables. I thought this was silly because this is a script and reading to and from a file would be a little silly so I though I could just make a different script that would set the variables.

The parent script

#!/bin/csh
...
...

./set_vars

echo $aVar

and my set_vars script looks something like

#!/bin/csh

setenv aVar "400"
echo $aVar

But aVar i snot defined in the parent script.

my question becomes... how do I make the child script set variables that the parent script can use, Or is there a better way to have a config file where someone can set variables.

This seems like a silly way to do it but the best way I can tell that doesnt require any file IO and still has a concise file to edit vars in.

+1  A: 

You should execute the "set_vars" script within the context of its parent. In C-shell, you achieve this with the "source" command :

#!/bin/csh
...
source set_vars
...
echo $aVar
jageay
I was absolutely positive I tried that, But gave it another go with your suggestion and it worked! so Thank you very much, and I don't know what dopey thing I did before. Does it make sense to just set variables like this instead of using a config text file?
mr odus