If I understand you correctly, an easier solution would be to have something like this in .bash_profile directly
cd $HOME/applications
./move_some_files
# make sure the exec is the last line
exec ./start_application
bash itself will then be replaced by ./start_application - therefore when ./start_application terminates, you'll be logged out and returned to the prompt.
This will work and kill the session thus logging the user out and returning them to the login screen, but only if you're already logged in and run this from the command line.
However
This doesn't work if the user logs in from the log in screen. The script does indeed take place - files are moved, the application is started, and files are replaced. But, it doesn't end the session - the normal log in procedure takes place i.e. the desktop is setup etc...
i am having the same problem in regards to exiting UNIX via a menu using the ksh. I want the menu option to log the user out, however the logout command has to be run from the command prompt and wont work from within the script. If u find an answer, I too am in need of it.