Linux - NewbieThis 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
Welcome to LinuxQuestions.org, a friendly and active Linux Community.
You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and absolutely free. Join our community today!
Note that registered members see fewer ads, and ContentLink is completely disabled once you log in.
If you have any problems with the registration process or your account login, please contact us. If you need to reset your password, click here.
Having a problem logging in? Please visit this page to clear all LQ-related cookies.
Introduction to Linux - A Hands on Guide
This guide was created as an overview of the Linux Operating System, geared toward new users as an exploration tour and getting started guide, with exercises at the end of each chapter.
For more advanced trainees it can be a desktop reference, and a collection of the base knowledge needed to proceed with system and network administration. This book contains many real life examples derived from the author's experience as a Linux system and network administrator, trainer and consultant. They hope these examples will help you to get a better understanding of the Linux system and that you feel encouraged to try out things on your own.
Click Here to receive this Complete Guide absolutely free.
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???
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.
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
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?
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.
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
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 {…}
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.