If you want to have a script run when a user logs in and/or logs out then you’ll likely want to look into using login and logout hooks. A hook is a script that runs as root (although you can execute as the user with su). Hooks are enabled in the /var/root/Library/Preferences/com.apple.loginwindow. You can do so using defaults, writing the path to the script into LoginHook as a string as follows:
defaults write com.apple.loginwindow LoginHook /scripts/script.sh
defaults write com.apple.loginwindow LogoutHook /scripts/scripts.sh



Archive
2 Comments
I am running into a problem when adding a Login script in Workgroup Manager under the Login preferences. My script fails to run on client machines that are bound to the OD master/Lion server. If I run my login script on the client itself, the script works successfully.
Could you or someone please help!??!!
Did you already add the other keys that let the login script work?