Mac OS X: Creating a login hook

Why here? Because I can never find this aricle when I need it. From Apple’s KB article:

[Things to keep in mind] with a login hook:

  • The script specified as a login hook must be executable.
  • The login hook will be run as root.
  • In the login hook script, the variable $1 returns the short name of the user who is logging in.
  • Other login actions wait until the hook has completely executed.

How to set up a login hook:

Mac OS X 10.3, 10.4, or later

  1. Open Terminal (Applications/Utilities).
  2. In the Terminal window, type: sudo defaults write com.apple.loginwindow LoginHook /path/to/script (where /path/to/script is the full path to the script that you want to execute when a user logs in—it doesn’t have to be in the user’s Home directory). This modifies the /var/root/Library/Preferences/com.apple.loginwindow file.
  3. Type your password at the prompt, then press Return.


appointive
appointive
appointive
appointive