Re: running login/logout scripts

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Filippos Klironomos wrote:
> Each time you login the files '.bash_profile' and '.bashrc' are
> executed so all you have to do is put your set of commands in one of
> them.
> 
> When you logout I am not sure if BASH executes the '.logout' file as
> well. You can try and see what happens.

Carlos Davila wrote:
> Thanks for your reply, I think the bash login files are also run every 
> time I open a gnome terminal (?)...which would wipe out any changes made 
> to the calendar. I am looking at the Gnome Device Manager (GDM).

More to the point, if you boot to a graphical environment, then bash
isn't necessarily run at all. Otherwise, the following lines from man
bash are relevant:

       When  bash is invoked as an interactive login shell, or as a non-inter-
       active shell with the --login option, it first reads and executes com-
       mands  from  the file /etc/profile, if that file exists.  After reading
       that file, it looks for ~/.bash_profile, ~/.bash_login, and ~/.profile,
       in  that order, and reads and executes commands from the first one that
       exists and is readable.  The --noprofile option may be  used when  the
       shell is started to inhibit this behavior.
                                                                                
       When  a  login  shell  exits, bash reads and executes commands from the
       file ~/.bash_logout, if it exists.
                                                                                
       When an interactive shell that is not a login shell  is  started, bash
       reads  and executes commands from ~/.bashrc, if that file exists.  This
       may be inhibited by using the --norc option.

In other words, if you log in to a login shell, you'll get .bash_profile
run at the beginning and .bash_logout at the end. Otherwise, you won't.

You can test this by putting echo statements in each file and seeing if
what you echo appears on screen.

As to what happens in a GUI, I think that depends on the GUI. Gnome has
a UI for setting startup programs, under the Preferences menu ->
Sessions -> Startup Programs tab.

You could also try dropping scripts into /etc/X11/gdm/{Post,Pre}Session.

Hope this helps,

James.

-- 
E-mail address: james | WARNING:  Pressing CTRL+ALT+DEL again will restart
@westexe.demon.co.uk  | your computer.  Then again, what won't?  You will
                      | lose unsaved information, and even supposedly saved
                      | information, in any case.  -- David P. Murphy


[Index of Archives]     [Current Fedora Users]     [Fedora Desktop]     [Fedora SELinux]     [Yosemite News]     [Yosemite Photos]     [KDE Users]     [Fedora Tools]     [Fedora Docs]

  Powered by Linux