SEARCH

Enter your search query in the box above ^, or use the forum search tool.

You are not logged in.

#1 2010-05-31 18:22:55

bearrider
New Member
Registered: 2009-04-02
Posts: 9

how to get .bash_profile to run at startup?

Hi,

I have CrunchBang 9.04.01 and am  trying to set up my java development environment.

Where do I set my environment variables like JAVA_HOME, ANT_HOME etc?

There was no ~/.bash_profile so I created one as below :

    #!/bin/bash
    export JAVA_HOME=/usr/lib/jvm/java-6-sun
    export PATH=$PATH:$JAVA_HOME/bin
   
    export ANT_HOME=/home/myhomedir/Development/ant
    export PATH=$PATH:$ANT_HOME/bin
   
But each time I log in, open a terminal and type echo $JAVA_HOME, nothing echoes.

However if I type "source ~/.bash_profile" and then type echo $JAVA_HOME, I get the correct value echoed for my JAVA_HOME

My question is, isn't .bash_profile supposed to run automatically at login anyway, why do I have to manually do a source each time?

How can I make it run at log in so that I don't have to run a source at the terminal?


Thanks

Offline

Help fund CrunchBang, donate to the project!

#2 2010-05-31 19:06:49

luc
#! Die Hard
From: Munich, Germany
Registered: 2010-03-21
Posts: 597

Re: how to get .bash_profile to run at startup?

if you want to have some stuff to be run when you open a termianl add it to ~/.bashrc
I think you can also add the path of other files there.(maybe like "source ~/.bash_profile")
If you want to have some stuff run at login you can add it to ~/.config/openbox/autostart.sh but don't forget the '&' at the end of each line.
If you have more questions just ask

Offline

#3 2010-05-31 20:33:27

corenominal
WRONG
From: Lincoln, UK
Registered: 2008-11-20
Posts: 5,081
Website

Re: how to get .bash_profile to run at startup?

bearrider wrote:

Where do I set my environment variables like JAVA_HOME, ANT_HOME etc?

There was no ~/.bash_profile so I created one...

Does '~/.profile' exist on your system? If it does, you could try popping them in there.


Ex-developer of #! CrunchBang. Follow me on Twitter smile

Offline

#4 2010-05-31 22:12:38

alon_h
#! Junkie
Registered: 2008-12-13
Posts: 269

Re: how to get .bash_profile to run at startup?

^ Also note that the comments on top of .profile says it will not be loaded if .bash_profile exist...

But I'm not sure if it, too, will load when you start a terminal, since it's supposed to be loaded for a login shell. If you use gdm or such you should probably put it in ~/.config/openbox/autostart.sh as luc said, [assuming you want those variables to set outside of interactive shell, say for eclipse / geany)

a.

Offline

#5 2010-06-01 04:43:06

johnraff
nullglob
From: Nagoya, Japan
Registered: 2009-01-07
Posts: 3,257
Website

Re: how to get .bash_profile to run at startup?

When you log in, via gdm or directly on a tty, .bash_profile or .profile will be executed, so if you open a terminal in a graphic environment it will be a subshell of that login shell and should inherit the variables you set in that file. (Also, .bashrc is executed every time you open such a terminal.) Scripts, run from a terminal or in the background, should also inherit those variables from *profile ( but not from .bashrc if in the background. )

Different systems seem to have different rules, but gdm on Ubuntu uses .profile I think.
Another complication is if you were using a different shell from bash: dash for example. Any file with bash in the name should be ignored, but eg .profile will be read. I haven't got a .bash_profile on Ubuntu-based #! 9.04, but Debian might be different... A common practice seems to be to put your settings in one file, and source it from the other so it should work either way. eg put settings in .profile and put this in .bash_profile:

[[ -r ~/.profile ]] && . ~/.profile

Confused enough? Try googling:
http://tldp.org/LDP/Bash-Beginners-Guid … 03_01.html
http://www.uluga.ubuntuforums.org/showt … ?t=1241288
http://stackoverflow.com/questions/4154 … nvironment

Last edited by johnraff (2010-06-03 05:20:12)


John     Please help us keep your forums manageable.
--------------------
( a boring Japan blog , idle twitterings  and GitStuff )
#! forum moderator

Offline

#6 2011-12-30 02:03:05

parlotti
Member
From: Project X
Registered: 2010-02-10
Posts: 27

Re: how to get .bash_profile to run at startup?

http://www.cyberciti.biz/faq/ssh-passwo … r-scripts/

I'm following the above tutorial on keychains and created a .bash_profile file coz  I didn't find one. However the commands appended in the .bash_profile file do not run automatically on startup.

Im running out of options to try so any help would be greatly appreciated.


This is Linux country. If you listen carefully, you can hear Windows reboot...

Offline

#7 2011-12-30 02:30:12

parlotti
Member
From: Project X
Registered: 2010-02-10
Posts: 27

Re: how to get .bash_profile to run at startup?

parlotti wrote:

http://www.cyberciti.biz/faq/ssh-passwo … r-scripts/

I'm following the above tutorial on keychains and created a .bash_profile file coz  I didn't find one. However the commands appended in the .bash_profile file do not run automatically on startup.

Im running out of options to try so any help would be greatly appreciated.

Solved:

ssh-askpass was not installed and was needed to help things along. Once I figured that out the rest was fun


This is Linux country. If you listen carefully, you can hear Windows reboot...

Offline

#8 2014-05-08 10:19:09

Ticheddeol
spambot
Registered: 2014-05-08
Posts: 11

Re: how to get .bash_profile to run at startup?

/spambot post removed

-s11

Offline

Board footer

Powered by FluxBB

Copyright © 2012 CrunchBang Linux.
Proudly powered by Debian. Hosted by Linode.
Debian is a registered trademark of Software in the Public Interest, Inc.

Debian Logo