bash - Unix /Linux - several applications using the same environment variables but different values? -


i looking advice on following below:

i have several applications , tools on server requires environment set variables etc them run.

many of these applications use same environment variables run different values.

some of these applications have multiple versions. e.g. prog v1.1, prog v1.2, prog v1.3 etc..

example: prog v1.1 uses environment variable var1 = val1, prog v1.2 needs var1 = val2 in order run. same variable, different values required each application.

another example is: prog3 require number of environment variables set prog4 doesn't need.

there logic involved when setting environment these applications, if file exists; this; else that


i've created shell scripts e.g. prog1setup.sh, prog2setup.sh etc setup environment each of these applications , then:

  1. start new shell every application needs run,
  2. run shell script ,
  3. run application inherits environment variables

what i'd know is, there open source tools available out there can used better manage there lots of applications? i've been doing research , came across tools such launcherd, supervisor , environment modules have not used of these before.

if has used of those, please provide insight on if can apply here or there else suggested?


thanks

since mentioned creating scripts, suggest creating prog1.sh with

#!/bin/bash export var1=val1 prog1 "$@" 

and creating prog2.sh with

#!/bin/bash export var1=val2 prog2 "$@" 

then, never run prog1 or prog2 directly. instead, run prog1.sh or prog2.sh. since shell scripts environment never affects calling shell, variable var1 exist when needed , disappear once script finishes executing.

alternative

some people prefer functions scripts because function definitions can conveniently stored in ~/.bashrc. examples of functions set needed environment variables:

date2() ( export tz=asia/tokyo; date "$@" ) date3() ( export tz=europe/paris; date "$@" ) 

these can used follows:

$ date2 wed jul  8 14:49:30 jst 2015 $ date3 wed jul  8 07:49:31 cest 2015 

Comments

Popular posts from this blog

toolbar - How to add link to user registration inside toobar in admin joomla 3 custom component -

linux - disk space limitation when creating war file -

How to provide Authorization & Authentication using Asp.net, C#? -