Login-Logout Detection + MYSQL

Hello all, I need to detect when a user has logged in/out into solaris 10, once the user has logged/unlogged I need to execute a MYSQL command, I was thinking on the /etc/.login file to execute a bash command that calls to mysql, but I just can not find how to execute something on the logout.

Somebody can help me?

Thanks in advance!

[353 byte] By [OdinDarkesta] at [2007-11-27 6:17:22]
# 1
IIRC C Shell has a logout function.alan
alan.paea at 2007-7-12 17:30:12 > top of Java-index,Solaris Operating System,Solaris 10 Features...
# 2
can you tell me how to get to it, or explain a little better? thanks!
OdinDarkesta at 2007-7-12 17:30:12 > top of Java-index,Solaris Operating System,Solaris 10 Features...
# 3

You can try the trap command as follows:

trap <command> 0

Put this in /etc/profile or users .profile and it should run <command> when the user exits the shell. You need to look at handling control-C (also with trap) and such to make sure the user cannot bypass the logout procedure.

Also you would need to check if the user has entered a shell by typing sh or exec sh.

Stuart_Flishera at 2007-7-12 17:30:12 > top of Java-index,Solaris Operating System,Solaris 10 Features...
# 4
if you are using bash shell then you can write your script in .bashrc for login and .bash_logout for logout. Hope this helps.rathi
rathia at 2007-7-12 17:30:12 > top of Java-index,Solaris Operating System,Solaris 10 Features...
# 5
> can you tell me how to get to it, or explain a little> better? thanks! http://www.cc.gatech.edu/classes/cs7321_99_winter/cshell-cheatsheet.pdfalan
alan.paea at 2007-7-12 17:30:12 > top of Java-index,Solaris Operating System,Solaris 10 Features...
# 6
I'd do it with auditing/bsm, as its very easy for users to bypass a .bash_logout or similar. Besides the .bash_logout wouldn't be executed if a user runs, for example:ssh <host> <command> .7/M.
mAbrantea at 2007-7-12 17:30:12 > top of Java-index,Solaris Operating System,Solaris 10 Features...