How do you logout from a session?

Hello all -

I'm finishing up a script that I wrote.

This is what I did:

I added some lines to the .bash_profile that will call my startup script:

cd $HOME/startup
./startup.scr

This startup script will create some directories, move some files, and then startup an application:

cd $HOME/applications
./move_some_files
./start_application

This is where I need some help:

Under Redhat Linux how do I kill the session and log the user out and display the login screen from my script?

Thanks!

I have not understood the above quite perfectly.

But, here is some break.

man exit
man logout

If I understand you correctly, an easier solution would be to have something like this in .bash_profile directly

cd $HOME/applications
./move_some_files
# make sure the exec is the last line
exec ./start_application

bash itself will then be replaced by ./start_application - therefore when ./start_application terminates, you'll be logged out and returned to the prompt.

Cheers
ZB

Thanks for the responses!

I've tried using logout in my script, but it doesn't do anything. I've tried using exit and that doesn't work either.

I've also tried starting the app within .bash_profile - as the last line and that won't work either!

I was able to kill the session by doing this within my script:

declare -r PIDNUM=`ps -ef | grep gnome-session`
kill -9 `echo $PIDNUM | cut -d' ' -f2`

Here's the kicker:

This will work and kill the session thus logging the user out and returning them to the login screen, but only if you're already logged in and run this from the command line.

However

This doesn't work if the user logs in from the log in screen. The script does indeed take place - files are moved, the application is started, and files are replaced. But, it doesn't end the session - the normal log in procedure takes place i.e. the desktop is setup etc...

I'm at a loss here.

Thanks.

i am having the same problem in regards to exiting UNIX via a menu using the ksh. I want the menu option to log the user out, however the logout command has to be run from the command prompt and wont work from within the script. If u find an answer, I too am in need of it.