Hi
I am using UNIX version.
HP-UX HP-UNIX B.11.00
I am writing a script which on certain condition should logout of unix.
But with exit command i am not able to get this..
Plz suggest how i should logout of the session directly.
Hi
I am using UNIX version.
HP-UX HP-UNIX B.11.00
I am writing a script which on certain condition should logout of unix.
But with exit command i am not able to get this..
Plz suggest how i should logout of the session directly.
kill -9 $$
Can you explain a little more?
Try starting the script with an "exec", then "exit" should log you out.
or put an exit in your script
and start your shell with
. script.sh
You want the script to logout of UNIX?
In your script...
kill -9 $PPID
I've never wanted to do this, but it might work...
(it does kinda assume that the parent process is the login one)
Basically you need to find the PID of the "-ksh", "-bash", or whatever process that's your login process - and kill it.
If your want to make sure the script always logs out once it's done, add something like
trap 'kill -9 $PPID' 0 1 2 9 15 16
to your script (man trap for more details)
And if it is buried under a layer of subshells ...
kill -9 `ps -o "%P"`
Hey! That's quite cool!
But you need to qualify it...
i.e...
/root #
/root # echo $0
-ksh
/root # echo $$
13898
/root # bash
/root # echo $$
13921
/root # ps -o "%P"
PPID
13896
13898
13921
/root # ps -ef | grep 13[89][95]
root 13896 1 0 18:52 ? 00:00:01 /usr/bin/Terminal
root 13897 13896 0 18:52 ? 00:00:00 gnome-pty-helper
root 13898 13896 0 18:52 pts/0 00:00:00 -ksh
root 13951 13898 0 18:54 pts/0 00:00:00 bash
root 13973 13951 0 18:55 pts/0 00:00:00 ps -ef
root 13974 13951 1 18:55 pts/0 00:00:00 grep 13[89][95]
as root, true
Hey guys, although your posts are valuable, I would like you paying more attention to your replies:
This forum is for HP-UX, the thread mentions hp-UX 11.00, so giving answers like
ps -o "%P" is innapropiate:
ard # uname -r
B.11.00
ard # ps -o "%P"
ps: illegal option -- o
usage: ps [-edaflP] [-u ulist] [-g glist] [-p plist] [-t tlist] [-R prmgroup]