Another option is to use pam - this will give you a precise way to define on-login actions.
For a generic action you can rely on pam_exec (http://manpages.ubuntu.com/manpages/hardy/man8/pam_exec.8.html). However, if you need to perform a more specific action in a safe way, there may exist more specialized pam modules which will make a better fit, such as commonly used pam_mount (for on-login mounts - http://manpages.ubuntu.com/manpages/hardy/man8/pam_mount.8.html) or pam_echo (for arbitrary messages to users - http://manpages.ubuntu.com/manpages/hardy/man8/pam_echo.8.html).
In general, pam is a very neat system for customizing logins, so you may want to look a bit more into it, instead of relying on potentially unsafe scripting, as others had suggested.
Given a fairly typical /etc/pam.d/system-auth we can employ pam_exec after login like this:
session optional pam_ssh.so
session required pam_limits.so
session required pam_env.so
session optional pam_mktemp.so
session required pam_unix.so
session optional pam_exec.so /usr/local/bin/my_prog
session optional pam_permit.so
/usr/local/bin/my_prog is arbitrary program being run after a successful user login.