PDA

View Full Version : log-out script




olej
Jul 28, 2010, 06:32 AM
Hi,

Where I should insert log-out script in mac os 10.5 ?

I would like control which time users login to computer and which time log out.

I made login script:

#!/bin/sh
mkdir /Volumes/log
mount_smbfs '//@svbk/LOG$' /Volumes/log
echo "$(date "+%Y-%m-%d, %T"), $(users), LOG-IN" >> /Volumes/log/logmac.rtf
umount /Volumes/log
killall Terminal

and logout script:
#!/bin/sh
mkdir /Volumes/log
mount_smbfs '//@svbk/LOG$' /Volumes/log
echo "$(date "+%Y-%m-%d, %T"), $(users), LOG-OUT" >> /Volumes/log/logmac.rtf
umount /Volumes/log
killall Terminal

but I don't now where I should insert logout script.
may somebody have a better idea to control time login,logout ?

Thx for help!!!



calderone
Jul 28, 2010, 10:08 PM
You can do this with hooks.

defaults write com.apple.loginwindow LoginHook /path/to/script.sh

defaults write com.apple.loginwindow LogoutHook /path/to/script.sh

This requires elevated rights, so you will need to pop a sudo in front of those.

Done.