Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

how to logout through a shell script 1

Status
Not open for further replies.

mckarl

Programmer
May 5, 1999
147
0
0
GB
Visit site
ok, i need a way to <b>logout</b> from within a <b>shell script</b>.<br>
basically, here's my plan.<br>
<br>
any previouse day -<br>
<br>
box administrator1: Please all remember to log out when you go home.<br>
<br>
me: home time ~~BBBRRRRRRRRRRMMMMMMMMM~~<br>
<br>
<br>
This morning:<br>
<br>
box administrator1: you forgot to log out <i>yadi ya ya ya </i><br>
me: *wakes up just as he finished, with a hangover* sorry.<br>
<br>
+++++++++<br>
<br>
Now, this repeats itself for 4 1/2 months now??<br>
<br>
So, i decide today, i am going to build a logout-<i>thingy</i>.<br>
<br>
1. Make use of the <u>at</u> command to run script at 5:00pm<br>
2. Make a program that is executed asking me if i want to continue, and if i dont reply after 30 seconds or so, it logs me <b>out</b>.<br>
3. Make a brew.<br>
<br>
++++++++<br>
<br>
Can anyone please tell me how to <b>logout</b> from within the script i want to create in step 2.<br>
<br>
++++++++<br>
<br>
Thanks!!!!<br>
<br>
Karl!<br>
<br>
<p> Karl<br><a href=mailto:mc_karl@yahoo.com>mc_karl@yahoo.com</a><br><a href= > </a><br> ~ ~ ~ ~<br>
K A R L<br>
~ ~ ~ ~
 
hmm<br>
<br>
You could tuck away the PID of your login shell in a file - then your 'at' job could kill it at a specified time. But that doesn't ask you if it's ok to do so. You could get it to send you mail - at one minute intervals until the logout time to give you a chance to cancel the kill job.<br>
<br>
-ml <p>Mike Lacey<br><a href=mailto:Mike_Lacey@Cargill.Com>Mike_Lacey@Cargill.Com</a><br><a href= Cargill's Corporate Web Site</a><br>
 
Can't you use the TMOUT variable of the Korn shell? if you give a value greater than 60 (seconds) it will log you out automagically...<br>
<br>
I hope it works
 
Elgis - I didn't know you could do that! Excellent <p>Mike Lacey<br><a href=mailto:Mike_Lacey@Cargill.Com>Mike_Lacey@Cargill.Com</a><br><a href= Cargill's Corporate Web Site</a><br>
 
Thanks guys!!<br>
<br>
Elgis, how would i use your method in a program?? i also never seen that TMOUT variable, and havnt found any information in any of my books. <br>
<br>
Mike, thanks, you have provided me with the knowlage i needed. However, i'm intregued about this TMOUT variable...<br>
<br>
<br>
Thanks guys!! <p> Karl<br><a href=mailto:mc_karl@yahoo.com>mc_karl@yahoo.com</a><br><a href= > </a><br> ~ ~ ~ ~<br>
K A R L<br>
~ ~ ~ ~
 
<br>
<br>
Well, i looked at it, and it's fairly easy to operate (Simple in fact)<br>
<br>
eg:<br>
<br>
############################<br>
<br>
&lt;.profile&gt;<br>
------------------------------------------------------------------------------------------------------------------------<br>
#set logout time as 2 mins:<br>
export TMOUT=160<br>
<br>
------------------------------------------------------------------------------------------------------------------------<br>
<br>
-- after 16 seconds (2 mins)<br>
<br>
Prompt:<br>
<br>
timout in 60 seconds:<br>
-- if no input--<br>
timeout waiting for input from user<br>
<br>
<br>
Simple!!!<br>
<br>
<br>
<br>
<br>
All you got to do, is set : TMOUT=160 in the profile (.profile) and BINGO!<br>
<br>
<br>
<br>
<br>
<br>
<br>
<p> Karl<br><a href=mailto:mc_karl@yahoo.com>mc_karl@yahoo.com</a><br><a href= > </a><br> ~ ~ ~ ~<br>
K A R L<br>
~ ~ ~ ~
 
You must to remember it is a Korn Shell variable, if you don't leave your terminal/session in the ksh, then you won't be logged out. The C Shell (or it is bash?) have TIMEOUT, with the same func.<br>
<br>
You can make the variable readonly with <br>
readonly TMOUT<br>
<br>
I hope it works<br>
<br>
PS: I'm a AIX/shell instructor, then I do know some little tricks ;-). And I like to be called &quot;Ramon&quot;
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top