LinuxQuestions.org
Download your favorite Linux distribution at LQ ISO.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie
User Name
Password
Linux - Newbie This Linux forum is for members that are new to Linux.
Just starting out and have a question? If it is not in the man pages or the how-to's this is the place!

Notices


Reply
  Search this Thread
Old 06-23-2005, 03:00 PM   #1
bigdog0007
LQ Newbie
 
Registered: May 2005
Location: NC
Posts: 26

Rep: Reputation: 15
Question logout after script runs


I wrote a menu script ... that launches automatically when a certain user logs in ... now i am trying to make it log the user out when they choose the Exit option... if i use the 'exit' command it just goes to the prompt... if I use the 'logout' command it gives me an error "not login shell: use 'exit'

What command do you use in a script to log the user out of the system without them going to the prompt???

Thanks, The
 
Old 06-23-2005, 03:18 PM   #2
rjlee
Senior Member
 
Registered: Jul 2004
Distribution: Ubuntu 7.04
Posts: 1,990

Rep: Reputation: 69
You can't do that like that. Basically, any given process cannot tell any other process to exit unless the other process explicitly lets it. This is done to encourage good design as well as as a security measure.

What you probably want to do here is to make the login script be the menu script that you're using; you can set this in /etc/passwd (it's the last field on the line).

Alternatively, you could modify the BASH script that calls your menu script to exit if it receives a given exit code.
 
Old 06-23-2005, 03:23 PM   #3
bigdog0007
LQ Newbie
 
Registered: May 2005
Location: NC
Posts: 26

Original Poster
Rep: Reputation: 15
I think I figured it out for myself ... instead of loging out at the end of the script... i use the exit command at the end of the .bash_profile for that user... the only thing I need to figure out now is:

How to keep them from [BREAK]ing (Ctrl + C) the program... or force a logout if they do.... any takers
 
Old 06-23-2005, 03:27 PM   #4
bigdog0007
LQ Newbie
 
Registered: May 2005
Location: NC
Posts: 26

Original Poster
Rep: Reputation: 15
Thanks RJLee... I didn't see your post when responded to mine ... Would changing the passwd file to point to my file stop them from [BREAK]ing the script and going to the prompt?
 
Old 06-23-2005, 03:38 PM   #5
rjlee
Senior Member
 
Registered: Jul 2004
Distribution: Ubuntu 7.04
Posts: 1,990

Rep: Reputation: 69
Yes, because there wouldn't be a prompt for them to go to. Breaking would exit the script, causing the user to logout.

I don't know what would happen with ctrl+y and ctrl+z though. This normally suspends a job for continued execution later; I think this is implemented by BASH though, so there shouldn't be a problem if you don't have a login shell. Still, there's no harm in trying it.
 
Old 06-23-2005, 04:04 PM   #6
bigdog0007
LQ Newbie
 
Registered: May 2005
Location: NC
Posts: 26

Original Poster
Rep: Reputation: 15
Wow... that is great.... the (Ctrl + C) accually caused it to lock that session ... thats fine with me ... the other 2 didn't seem to have any effect at all... and when the exit option is use it logs out ... just what the doctor ordered


THANKS!!!!
 
Old 06-24-2005, 06:42 PM   #7
rjlee
Senior Member
 
Registered: Jul 2004
Distribution: Ubuntu 7.04
Posts: 1,990

Rep: Reputation: 69
Quote:
Originally posted by bigdog0007
Wow... that is great.... the (Ctrl + C) accually caused it to lock that session ... thats fine with me ... the other 2 didn't seem to have any effect at all... and when the exit option is use it logs out ... just what the doctor ordered


THANKS!!!!
If you want to stop it from locking, then you probably want to look at installing a handler for the SIGTERM signal. In bash, you can do this with the trap command; in Perl you can use $SIG{TERM} = sub {}
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

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 Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
a script that runs wget every 3 minutes Menestrel Programming 3 07-26-2005 12:22 PM
CGI script downloads, not runs! hamish Linux - Software 7 01-17-2005 12:00 PM
creating shell script that executes as root regardless of who runs the script? m3kgt Linux - General 13 06-04-2004 11:23 PM
Where can I the script that runs the forum? patpawlowski LQ Suggestions & Feedback 5 03-17-2004 05:37 PM
a script that runs every 5 minutes? zovres Linux - Newbie 5 08-19-2003 01:14 AM


All times are GMT -5. The time now is 01:18 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration