RE: logs versus bash...
Hi miguelcoma,
There are numerous solutions, depending upon what you need and how you want to be notified, and how willing you are to "get dirty" with bash coding I suppose.
For instance, the system log file contains lines that have "loginwindow" in them, and these lines list whoever successfully logs into your machine. So in the Console.app window if you search for "loginwindow" you will see a list of the users's logins. There are also various tools for watching events happening in the logs. I'm sure there are ones for the Mac OS X, but I haven't looked into them because I use a couple of Linux ones that I build under the Mac OS X. For a simpler one, you might look into "logwatch" that can be build using the MacPorts system.
But let's say that you just want to be notified when some user logs into your computer. Then you might write a simple bash script to check if that user is logged in and notify you if he/she is. If you then run this script repeated (possible through a number of mechanisms, all the way from "cron" through "Automator.app"), say once a minute, then you will be notified if the user logs in on a minute by minute basis. For example, the following line of bash:
Code:
if who | grep -i guest; then echo "guest"; else echo "no guest"; fi
checks if the user "Guest" is logged into your computer, and, if so, prints "guest" to your terminal. If "Guest" is not logged in, then "no guest" is printed to the terminal. This is just a template bash command line, as you would change the "echo "guest"" and "echo "no guest"" lines to run other shell scripts to do anything you might want done, such as notifying you through the Notification Center. In fact, the "terminal-notifier.app" is perfect for this job. If you replace the "echo "guest"" in the above code with the appropriate "terminal-notifier -message "Guest login"", then you will receive a Notification telling you of the "Guest login" whenever Guest logs into your computer. This sounds like a winner to me...
Good luck,
Switon
P.S. The bash code line is an IF statement that runs the "who" command to get the list of users logged into your computer. This list is piped ("|"), or sent, to the "grep -i" command that checks if the user "guest" is currently logged in. If so, then the IF is satisfied and the THEN part of the IF is executed, that is, "echo "guest"" is run to print "guest" on your terminal. If the IF statement is not satisfied, i.e., Guest is not logged into your system, then the ELSE portion of the IF statement is executed, that is, the "echo "no guest"" is executed which prints "no guest" on your terminal.