I have the following simple program:
int main ()
{
char * v = getenv ("TEST_VAR");
cout << "v =" << (v == NULL? "NULL": v) << endl;
return 0;
}
These lines are added to the .bashrc file:
TEST_VAR = "2"
export TEST_VAR
Now, when I run this program from a terminal window (Ubuntu 10.04), it prints v = 2. If I run the program differently: using the launcher or from Eclipse, it prints NULL. I think this is due to the fact that TEST_VAR is defined only inside the bash shell. How to create a constant Linux environment variable, accessible anyway?
source
share