What I am trying to do in the OS Module in Python is to perform the ‘logout’ action that one would normally perform on the command line. I write:
os.system('logout')
BUT, when I do that, I get:
sh: line 0: logout: not login shell: use `exit'
So, I tried making it:
os.system('exit')
Which merely exits out of the python program, it does NOT perform the ‘logout’.
How do I do this? Is it possible???
“Logout” is something that happens when a shell that is started as a “login shell” exits. No other program can do a
logoutcommand, because only the act of exiting the login shell does a logout.Having said that, you might be able to find an appropriate login shell belonging to the current user, and kill it. Make sure you get the right one though, users can be logged in more than once and killing the wrong one would be annoying.