The UNIX and Linux Forums  
Hello and Welcome from United States to the UNIX and Linux Forums! Thank You for Visiting and Joining Our Global Community.

Go Back   The UNIX and Linux Forums > Operating Systems > Linux > Red Hat
.
google unix.com



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.

More UNIX and Linux Forum Topics You Might Find Helpful
Thread Thread Starter Forum Replies Last Post
Login and logout time of a session sharif UNIX for Advanced & Expert Users 1 03-10-2008 05:10 AM
.logout sharif SUN Solaris 3 12-24-2007 05:08 AM
.logout help 2dumb Shell Programming and Scripting 3 05-10-2007 11:49 AM
logout zam UNIX for Dummies Questions & Answers 2 12-28-2006 07:23 PM
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

Closed Thread
English Japanese Spanish French German Portuguese Italian Dutch Swedish Russian Norwegian Hungarian Hebrew Danish Powered by Powered by Google
 
LinkBack Thread Tools Search this Thread Rate Thread Display Modes
  #1 (permalink)  
Old 03-24-2005
Heron Heron is offline
Registered User
  
 

Join Date: Mar 2005
Posts: 10
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!
  #2 (permalink)  
Old 03-25-2005
bhargav's Avatar
bhargav bhargav is offline Forum Advisor  
Registered User
  
 

Join Date: Sep 2004
Location: USA
Posts: 511
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
  #3 (permalink)  
Old 03-25-2005
zazzybob's Avatar
zazzybob zazzybob is offline Forum Advisor  
Registered Geek
  
 

Join Date: Dec 2003
Location: Melbourne, Australia
Posts: 2,100
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 (permalink)  
Old 03-25-2005
Heron Heron is offline
Registered User
  
 

Join Date: Mar 2005
Posts: 10
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.
  #5 (permalink)  
Old 04-25-2005
sanitywonko sanitywonko is offline
Registered User
  
 

Join Date: Apr 2005
Posts: 5
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

Bookmarks

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On




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


Powered by: vBulletin, Copyright ©2000 - 2006, Jelsoft Enterprises Limited. Language Translations Powered by .
vBCredits v1.4 Copyright ©2007 - 2008, PixelFX Studios
The UNIX and Linux Forums Content Copyright ©1993-2009. All Rights Reserved.Ad Management by RedTyger

Content Relevant URLs by vBSEO 3.2.0