Vincular una variable de entorno de Linux a otra

Is it possible in linux to bind an environment variable to an existing one. The value of environment variable should change dynamically if the dependent variable is changed.

preguntado el 24 de mayo de 14 a las 14:05

What kind of problem are you trying to solve? -

I was deploying an app on Openshift PaaS. Openshift give us env vars - OPENSHIFT_NODEJS_IP, to keep code platform agnostic, I wanted to include an env variable as NODEJS_IP, which automatically gets binded to the platforms' env variable, as the name of env variable would be different in each PaaS. Well there are other ways to solve this problem as well, but if the answer to my question was yes, could have been solved this way. -

1 Respuestas

AFAIK that is not possible. There are actually dos problems involved here:

  1. an environment variable is something pasivo, nothing but a string. There is no active component to it that might execute some monitoring action. This leads to the next point:

  2. such a monitoring actions would require some sort of service running. That is absolutely possible, a service monitoring something, however you won't have access to some other processes environment variable that way. The environment is something process specific, not session or system specific.

Aun asi if you would detect some variables content change and react to it, there is no way for you around the process boundary. The only thing you could implement is to spawn a nueva process with an environment setup to your liking.

contestado el 24 de mayo de 14 a las 14:05

No es la respuesta que estás buscando? Examinar otras preguntas etiquetadas or haz tu propia pregunta.