Unix Environment Script

Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Unix Environment Script
# 1  
Old 01-05-2006
Unix Environment Script


I was wondering what is the best way to write a centralized unix environment script. This script would set the application environment variables per specific environment. e.g. dev, qa, test or prod.

We currenlty have 2 types of env files e.g. .envfile and set.env per environment. These contain all the necessary application variables that need to be set. And these are set through the calling script via . .envfile or . set.env (we dot the file to set/export the variables.) We would like to consolidate these env files.

How could we accomplish to have only one env shell script to set 4 different environemnts? I guess this need to be based on "host" and/or "user" per environment.

I would appreciate your thoughts on this topic.

Thanks in advance,

# 2  
Old 01-05-2006
Since you want it for all users put the code in /etc/profile.

You would be better off keeping those variable declarations if four separate files:

Then execute the correct script based on hostname:
if [ $hostname = "dev" ] ; then
  .  /path/to/dev_env.shl
........ and so on

# 3  
Old 01-05-2006
Thanks for the information.

Do we name the 4 env files suffixed with .sh. We currently have 2 diff types of env files as .envdev and set.dev. I also want to make sure these files just have variables exported and what is the industry standard for naming these environment files.

# 4  
Old 01-05-2006
oops a slight typo there by Jim

if [ $hname = "dev" ] ; then ### not $hostname
. /path/to/dev_env.shl
........ and so on


but want to know, is the hostname the criteria to decide what env script you are going to run ? If yes, then you can simply put the respective scripts in the /etc/profile directly, instead of having a wrapper script, coz anyway when you know what you want to run on "dev" you even dont want to check if it is "dev" on "dev", so simply put that "dev.sh" in /etc/profile of "dev" and same for others.
# 5  
Old 01-07-2006
We do not have a separate server for each environment. Infact we have all the environments except pord on the same server. Does it make sense to set the env variable in the .profile per user account per environment or set using the centralized env script.
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Using Datastage environment variables in Unix script

Hi All, I am using ETL tool Datastage and is installed on Linux environment. Few environment variables are set in datastage. Now my requirement is to use those environment variables in a unix script. Is there any option I can do it? Sugeestions from people working on datastage and linux... (1 Reply)
Discussion started by: bghosh
1 Replies

2. Shell Programming and Scripting

How to pass the environment name while calling java program from unix script?

Hi, I'm trying to test one unix shell script in dev environment. But I'm not sure how to pass the environment in my java program calling code. I'm trying to use -DconsumerEnv="DEV" but unfortunately I get 'null' while trying to print the value from java class. System.out.println("Environment: "+... (4 Replies)
Discussion started by: Pramit
4 Replies

3. Shell Programming and Scripting

How to send email using shell script in UNIX, Is any environment setup required in Mac OS X ?

Hi All, I am using Mac OS X (Leopard OS). I am very new to UNIX. My requirement is that, by running a shell script, I create a log file. So I have to send a mail having that log file attached. What I tried to do is, I simply tried to check,whether this direct command works or not. So I... (2 Replies)
Discussion started by: Afreen
2 Replies

4. Shell Programming and Scripting

common UNIX script which is to work in HP and SUN environment

I have two different UNIX scripts for updating Co-ordinate points which are working fine seperately in HP and SUN environments. But I am trying to write a common UNIX script which is to work in HP and SUN environment. The following are the scripts i am using SUN: #!/bin/ksh info () {... (6 Replies)
Discussion started by: ramkumar2yk
6 Replies

5. UNIX for Dummies Questions & Answers

unix environment

Hi, Can anyone recommend a site where one can practise UNIX scripting . I don't have UNIX on my machine however I have heard there are some sites which let you log on to their servers for free. Thanks Rohit (2 Replies)
Discussion started by: rohitv
2 Replies

6. Shell Programming and Scripting

programming for unix environment

i have to make a menu based program to allow iusers to select the system information about their machine that they want. All i have been taught is how to enter commands at the command prompt like simple commands such as pwd and cd directory to change directory (not even sure if that is right). But... (1 Reply)
Discussion started by: carlvernon
1 Replies

7. UNIX for Dummies Questions & Answers

unix develop environment

hi! i am Carlos i study @ UABC (Autonomy University of Baja California)... i have a final project.... i need to make a presentation of the new... unix develop environment... but... i have some problems with that.... could you tell me something to help me? (0 Replies)
Discussion started by: Nx GT-R
0 Replies

8. UNIX for Advanced & Expert Users

Unix environment issues

I'm having a problem with AIX 4.3.3 and I figured someone here might be able to help me. I'm running a program 24/7 and I want to handle the day light savings issue without restarting the program since my users won't like it. I don't have the option of setting the time for the DLS in advance,... (4 Replies)
Discussion started by: Eff
4 Replies

9. UNIX for Dummies Questions & Answers

personalizing my unix environment

I share a login id/password with several folks so I don't like to change the .profile or other environment variables (e. g., set ignorecase in vi) that other users may expect to be set. Any suggestions to tailor my environment that will not affect other users (2 Replies)
Discussion started by: artjaniger
2 Replies

10. UNIX for Dummies Questions & Answers

MixWindows UNIX environment

I was wondering if anyone has had any experience in this area. The company that I work at is trying to bring a Windows 2000 server online and have the UNIX workstations and Clients connect to it like it is anothe UNIX box. They have been using Windows Services for UNIX to do this but are having... (1 Reply)
Discussion started by: kaikara1
1 Replies
Login or Register to Ask a Question

Featured Tech Videos