In our current environment we have each of our testing levels on individual servers (running Korn shell). So, there is a server for dev and test, and 2 servers for qa and prod. I have several scripts that utilize a code that is dependant on the server where it resides. While I was the only person using these scripts, I had that value hard coded in my scripts (they were quick and dirty scripts). Now we have several folks that will be supporting this and I want to keep the scripts in a central repository and change this value to be an environment variable.
My thought is to set this as an environment variable in the users .profile. Then the scripts will use that variable, instead of having to change it for each server/test level.
My assumption, and from everything I've read, is that if I export the variable in my profile, it should be available to scripts when executed. But, that is not what I am seeing. And these scripts are executed by the user from the command line.
Here is an example. Any help would be appreciated.
.profile:
VAR=server_a
export $VAR
script:
some_command $VAR #executes command passing in $VAR
When I do this, $VAR does not seem to contain server_a. It is empty instead. However, if I echo out $VAR at the command line, it does equal server_a.
A solution that does seem to work, is to set the variable in a .kshrc file and execute that in my script prior to using it. But I would prefer to have it set in the profile and have it available for the scripts.
Any help would be appreciated. Thanx