I want, when a linux user exits from a shell script, that it also logs out from the bash shell. Is this possible?
|
Instead of starting the script normally, |
|||
|
|
|
Depending on what you are trying to accomplish, you could use the script name instead of the shell in /etc/passwd. The last entry in /etc/passwd (everything after the last colon) is the shell that is run when the user logs on. By changing this to the name of your script, when the script ends, then by definition, so does the shell. ** Be very careful editing /etc/passwd however, as you could lock yourself out of your machine. Apparently you can do this with
which would be the safer way to make this change. |
|||
|
|
|
End your script with $PPID is the process ID of the parent process. |
|||||||
|
|
with kill ?
Edit: as said in the comments, it works better with PPID
|
|||||||
|
|
It is possible to do this if you include an EXIT at the end of your script, which tells the bash shell to terminate. |
|||||||||
|