2

I have my bash_profile environment setting as follows:

if [ `hostname` = "devoraebs01" ]; then
   echo `hostname -f`
   . /appl_top/deverp/appl/APPSDEVERP_devoraebs01.env

When I log into this host, it echoes the hostname correctly. But I've noticed that when I try to execute some shell script, I get errors until I run the ". /appl_top/deverp/appl/APPSDEVERP_devoraebs01.env" manually.

Nothing appears to be incorrect with the syntax. Any idea why this isn't getting set correctly at my initial login?

Here's the entire contents of . /appl_top/deverp/appl/APPSDEVERP_devoraebs01.env:

customfile=/appl_top/deverp/appl/customDEVERP_devoraebs01.env 
if [ -f $customfile ]; then 
   . /appl_top/deverp/appl/customDEVERP_devoraebs01.env 
fi     
   . /db/u01/conf_top/DEVERP_devoraebs01/8.0.6/DEVERP_devoraebs01.env  
   . /appl_top/deverp/appl/DEVERP_devoraebs01.env

I am logging into the host via PuTTY.

  • if [ `hostname` == "devoraebs01" ]; ? – taliezin Mar 12 '15 at 14:34
  • I don't think that's the fix. If it were, then my echo hostname -f would not run at login. But it does. – Andrew Hummel Mar 12 '15 at 14:38
  • and in your *.env file you are exporting something? – taliezin Mar 12 '15 at 14:51
  • 1
    Does the env file do an export of certain variables or a set? – rahul Mar 12 '15 at 14:57
  • 1
    Please edit your question and i) add the contents of /appl_top/deverp/appl/APPSDEVERP_devoraebs01.env (or, even better, just give us a minimal example that reproduces the problem) ii) explain how you log into the host since that changes what files are read at login. – terdon Mar 12 '15 at 14:58
0

.bash_profile does not get executed for non-login shells, so if you are running a command and expect it to load in env settings from .bash_profile, that will not happen.

Try creating a .bashrc file instead.

  • So I created a file called .bashrc in my home directory and moved my env settings script into there. Does not appear to run after login. Am I missing something? – Andrew Hummel Mar 13 '15 at 12:51
  • I also added this to my .bash_profile to have it call .bashrc on login. It calles it but still not setting the env variable. – Andrew Hummel Mar 13 '15 at 13:26
  • if [ -f ~/.bashrc ]; then source ~/.bashrc fi – Andrew Hummel Mar 13 '15 at 13:26

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.