How to have a shell script terminate the login shell (parent)?

How to have a shell script terminate the login shell (parent)?

Post by Donald S. Teis » Wed, 29 Dec 1993 12:29:24



Sorry if this is a FAQ ...

I am trying to create a ksh script, invoked by .profile, to be
used as a simple menu for novices.

One of the case choices that should be available is "logout",
not just exit the menu script.

How?

 
 
 

How to have a shell script terminate the login shell (parent)?

Post by Gunther Feuereis » Wed, 29 Dec 1993 16:45:32



: Sorry if this is a FAQ ...
:
: I am trying to create a ksh script, invoked by .profile, to be
: used as a simple menu for novices.
:
: One of the case choices that should be available is "logout",
: not just exit the menu script.
:
: How?

Hmm..my first idea would be to kil the parent process, assuming that the
menu is invoked at login, just kill the login process, as well as the
menu process. As ksh is based on sh, I'm pretty sure there is a way in
shto recognise the PPID of the current process, as well as the current
PID, then all you do is kill off PID and PPID - however this is a bit
brusque, and there might be a nicer way.

As for how to identify the PID's - I can't remember offhand, but the
book by Kernighan and Pike mentions it from memory.

rgds..

--
Gunther Feuereisen                     Australian Graduate School of Management


 
 
 

How to have a shell script terminate the login shell (parent)?

Post by Kevin J Brandi » Wed, 29 Dec 1993 22:22:54



Quote:>Sorry if this is a FAQ ...

>I am trying to create a ksh script, invoked by .profile, to be
>used as a simple menu for novices.

>One of the case choices that should be available is "logout",
>not just exit the menu script.

>How?

'kill -9 0' should do it for you

--
 kevin j brandich, systems analyst      |                                    


 
 
 

How to have a shell script terminate the login shell (parent)?

Post by Joshua A. La » Wed, 29 Dec 1993 23:00:47


Well, if the .profile starts the ksh script, it will execute it just like it
would under normal circumstances - the program gets run, and then the .profile
continues. So, just put "logout" right after the program name. When the
program exits, the .profile will continue, see "logout", and logout the user.

Of course, this brings up the question of letting other people use your
account, but that's between you and your sysadmin...
--
 Joshua A. Laff, CRL Head Operator, University of Illinois    (217) 333-7408

_______________________________________________________________________________
Disclaimer: If I were speaking for the UofI, I wouldn't be paying tuition.

 
 
 

How to have a shell script terminate the login shell (parent)?

Post by Jerry Rocte » Thu, 30 Dec 1993 07:41:35




Quote:>Sorry if this is a FAQ ...

>I am trying to create a ksh script, invoked by .profile, to be
>used as a simple menu for novices.

>One of the case choices that should be available is "logout",
>not just exit the menu script.

>How?

Create your menu, put it in a script, call it for example menu.

Then, last line of your .profile says:

        exec menu

Your menu has an exit function, when you select the exit option, you
will be logged off.

If you don't understand or you want more information, send me some
email.

--
 __^__                                                              __^__
( ___ )------------------------------------------------------------( ___ )

 |___| Aritfical intellegence is no match for natural stupidity!    |___|