How do you logout from a session? | Unix Linux Forums | Red Hat

  Go Back    


Red Hat Red Hat is the world's leading open source technology solutions provider with offerings including Red Hat Enterprise Linux (RHEL), Fedora, open source applications, security and systems management, virtualization, and Services Oriented Architecture (SOA) solutions.

How do you logout from a session?

Red Hat


Closed Thread    
 
Thread Tools Search this Thread Display Modes
    #1  
Old 03-24-2005
Heron Heron is offline
Registered User
 
Join Date: Mar 2005
Last Activity: 10 July 2005, 2:18 PM EDT
Posts: 10
Thanks: 0
Thanked 0 Times in 0 Posts
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!
Sponsored Links
    #2  
Old 03-25-2005
bhargav's Avatar
bhargav bhargav is offline Forum Advisor  
Registered User
 
Join Date: Sep 2004
Last Activity: 26 July 2012, 3:38 PM EDT
Location: USA
Posts: 512
Thanks: 0
Thanked 2 Times in 2 Posts
Quote:
Under Redhat Linux how do I kill the session and log the user out and display the login screen from my script?
I have not understood the above quite perfectly.

But, here is some break.

man exit
man logout
Sponsored Links
    #3  
Old 03-25-2005
zazzybob's Avatar
zazzybob zazzybob is offline Forum Advisor  
Registered Geek
 
Join Date: Dec 2003
Last Activity: 13 May 2013, 9:02 AM EDT
Location: Melbourne, Australia
Posts: 2,185
Thanks: 3
Thanked 24 Times in 23 Posts
If I understand you correctly, an easier solution would be to have something like this in .bash_profile directly


Code:
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
    #4  
Old 03-25-2005
Heron Heron is offline
Registered User
 
Join Date: Mar 2005
Last Activity: 10 July 2005, 2:18 PM EDT
Posts: 10
Thanks: 0
Thanked 0 Times in 0 Posts
Quote:
Originally Posted by zazzybob
If I understand you correctly, an easier solution would be to have something like this in .bash_profile directly


Code:
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.
Sponsored Links
    #5  
Old 04-25-2005
sanitywonko sanitywonko is offline
Registered User
 
Join Date: Apr 2005
Last Activity: 28 April 2005, 11:16 PM EDT
Posts: 5
Thanks: 0
Thanked 1 Time in 1 Post
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.
Sponsored Links
Closed Thread

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

More UNIX and Linux Forum Topics You Might Find Helpful
Thread Thread Starter Forum Replies Last Post
session logout arvindng Shell Programming and Scripting 1 02-05-2009 07:25 PM
I am not able to login in gnome session and java session in Sun solaris 9& 10 durgaprasadr13 Solaris 0 12-10-2008 08:13 AM
Login and logout time of a session sharif UNIX for Advanced & Expert Users 1 03-10-2008 05:10 AM
sqlplus session being able to see unix variables session within a script 435 Gavea Shell Programming and Scripting 2 07-03-2006 10:11 AM



All times are GMT -4. The time now is 01:41 PM.