How to set and use external variables in shell scripts?
Posted on 2009-04-03
We have 4 layers(dev, tst, at, pd) on the same server where a korn shell script will run on all 4 layers.
I want to make the script generic where I have 4 copies of the same script, one on each layer. I'd like to determine which layer the script is running from using a form of environment variable. I've been told I can create an environment file that will exist on each layer with it's correcponding layer value and then refer to that variable in the shell script.
As I'm not proficient in unix, I need to know how I may be able to do this,
For instance I can create the following ksh file that would reside in the same location as the shell script:
ENV_LAYER=dev # this env variable needs to be updated to dev, tst, at, pd
But then I don't know how or if I can access this variable in the script???