Hello Managers,
Here is a summary of all of the responses I got for this problem (stated)
> If you use the Korn Shell, and have an Korn
> Shell written application which performs various tasks including LOGGING
> off, there is no "logoff" (logout) command in Korn Shell nor in DEC UNIX.
> Performing an "exit" in a ksh script only exits the script. Thus my
> users in this script can not logoff the system using the script.
Reply from: Donald L. Ritchey <dritchey_at_cecc.chi.gov>
Try running the command 'stty 0' to set the baud rate on your tty to
0, effectively sending a hang-up signal to the connected shell and all
child processes.
Reply From: Jason Neil <jan_at_nzxray.galen.co.nz>
try setting up aliases for commands. see ksh - alias
Reply From: Hannu Paakko <Hannu.Paakko_at_ktt.ktt.fi>
You could send hup-signal to the shell process.
In .profile set
export MPID=$$
logout script:
kill -hup $MPID
Reply From: Dave Roberts <djr_at_saa-cons.co.uk>
Issuing a `kill 0` should kill the login process for that user. This
should work all flavours of Un*x. AIX is fairly unique in having a
logout command, it also doesn't exist on SCO, HP or DRS/NX.
Reply From: Eric Bennett <bennett_at_hpel.umd.edu>
You could define a function or alias which exec's your script:
alias logoff="exec /somepath/logoff"
You could do something like this to kill the parent process:
set `ps -fp $$`
kill -HUP $3
exit ## Never reached?
If you are persistent, how about:
upkill () {
set $1 `ps -o ppid -p $1`
if [ 0$3 -gt 1 ]; then upkill $3; fi
/bin/kill -HUP $1 2>/dev/null
}
upkill $$
Of course, this will also try to kill inetd and telnetd. (Shrug)
Reply From: Jon Trulson <trulsonj_at_mscd.edu>
You might try putting a kill -15 0 (or kill -9 0) in your
script. PID 0, when passed to a kill command will send that signal to
the process group. So doing a kill -9 0 in your script will kill all
processes started by the user that are still a part of the user's
process group.
Reply From: Jason Neil <jan_at_nzxray.galen.co.nz>
Reply From: msdc!daleb_at_uunet.uu.net (William D. Blasingame)
The 'logout' command is a builtin for csh, and, as you noted,
doesn't appear to be there for ksh. The problem you describe
might be solved by:
- letting the "Korn Shell written application" be the users' login
shell (in /etc/passwd). This way, when they exit this shell,
they're logged off.
- execute the application from the login shell with the 'exec' shell
command, thus making the current shell the application and not
creating a new (i.e., another) process. Again, when they quit
the current shell, they're off.
Thanks again from everyone for the responses.
===============================================================================
Kenneth Atchinson Baldwin-Wallace College
UNIX System Administrator 275 Eastland Rd.
katchins_at_baldwinw.edu Berea, Ohio 44017
Voice: (216) 826-6967 FAX: (216) 826-6545
Received on Tue Jan 09 1996 - 21:28:57 NZDT