Csh run script config file, and variables
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 tha开发者_如何学Pythont 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.
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
精彩评论