KSH logging of users activity

From: Mohan Kumar (mohan_6789@yahoo.com)
Date: Wed Dec 12 2007 - 23:29:37 EST


Folks,

I have a requirement of logging users activity (the commands executed
by them) to a LOGHOST. To some extent, I got the solution to it and it can be
found at
http://blogs.sun.com/chrisg/entry/logging_commands_in_korn_shell#comments
..... Thanks to Chris for this solution. :-)

------------------------From
above link... (Chris's web blog)------------------------------
Type this into
your shell and you can capture the command, it's return code and the current
working directory.
function dlog
{
        typeset -i stat=$?
        typeset
x
        x=$(fc -ln -0)
        logger -p local3.debug -t "ksh $LOGNAME $$"
Status $stat PWD $PWD \'${x# }\'
}
trap dlog DEBUG

(note that there is
a tab after the # in ${x# })
-----------------------------------------------------------------------------
---------------------

I am able to configure the logging to a central system
and it is working to almost 90% cases. :-) Now the catch is, if I am using two
or more pipes in a command, then it is not logging and exiting/pushing me out
from the system and the session terminates. For example, if I run the
following command:

# ls -l | grep mohan -----> It works and
gets recorded in the logs.
# ls -l | grep mohan | grep txt -----> It doesn't
work and terminates the session.

When I disabled the logging, all commands
are working without any problem. Can anyone let me know what correction can be
done in the function so that it can accept more pipes.

OR -- Any other
solution which can do the equivalent (KSH logging).

Cheers,
Mohan
_____________________________________________________________________________
_______
Be a better friend, newshound, and
know-it-all with Yahoo! Mobile.
Try it now. http://mobile.yahoo.com/;_ylt=Ahu06i62sR8HDtDypao8Wcj9tAcJ
_______________________________________________
sunmanagers mailing list
sunmanagers@sunmanagers.org
http://www.sunmanagers.org/mailman/listinfo/sunmanagers



This archive was generated by hypermail 2.1.7 : Wed Apr 09 2008 - 23:42:36 EDT