How can ensure that a environment variable is set for a user? I have
MYVAR=whatever
export MYVAR
in the ~/.bash_profile but a report from the user suggests that it hasn't worked for them. What could have happened?
|
How can ensure that a environment variable is set for a user? I have
in the ~/.bash_profile but a report from the user suggests that it hasn't worked for them. What could have happened? | ||||
|
feedback
|
|
Use the PAM module called | |||
feedback
|
|
Some excerpts from the bash manpage:
Could this explain why it "hasn't work for them"? | |||
|
feedback
|
|
From within your code, you could do:
if you're setting it from something like the user's own .bash_login or .bashrc, are they sudo'ing out of their environment? Exporting a variable will only work if the subsequent use of that variable is dependent to the export; i.e., export during their login process should work for anything they run, unless they su/sudo, in which case they're actually leaving that environment and then executing whatever they're doing. | ||||
|
feedback
|
|
It should probably be set in Also, you list the file as | |||||
|
feedback
|
|
jjujuma First ensure that the user is using bash. He/She might be using csh. If you want it set for just that user and they are using bash/sh then you need to put it in the .bashrc file. If csh/tcsh you need to put it in the .cshrc/.tcshrc. If you want it set globally for all users /etc/profile and /etc/csh.cshrc for bash/tcsh respectfully will get you up and going! HTH | |||
|
feedback
|
~/.bash_profile? – Pascal Thivent Sep 23 '09 at 15:22