Hi,
I have a script giving option to allow user who run the script log out the server.
I used 'exit' when user chose this option. But it didn't work the way I wanted. It only exit the program not the machine.
I used 'logout' after 'exit'. Still not working.
Anyone has some ideas?
First off, why it didn't work...
code
...
exit
logout
then the process gets to the exit and does that - never sees the logout command. If you put
...
code
...
logout
exit
then it should complain that either logout wasn't found or that it isn't the login shell - you would have to source this script to run under the parent process to actually logout the person.
Hi,
I still need help to logout of the servers once the script finished.
I wrote in the shell script that if user choose option 1, they can log out the system.
I coded it as exit. But this only allows to exit the program.
I'd like to know if there is a way to not only exit the program but also logout the Linux server.
I'd use the "exec" built-in function. It runs the script in place of the current shell - so when the script exits so does the session. Handy when writing user menu scripts because they cannot break out to the shell.
and it exited Unix from my menu program. However i was accessing UNIX via telnet and this did not return me to a login screen, it completely exited the telnet window.